Commit 953a52
2024-10-31 15:02:36 Qwas: Save openwrt 使用 nginx| /dev/null .. openwrt/openwrt \344\275\277\347\224\250 nginx.md | |
| @@ 0,0 1,56 @@ | |
| + | # OpenWrt 使用 Nginx |
| + | |
| + | 由于 OpenWrt 默认使用了 uhttpd,占据了 Web 端口 uhttpd 可以执行 luci 的 cgi 文件(路由器管理界面),但 Nginx 不行。 |
| + | |
| + | ## 修改 uhttpd 配置 |
| + | |
| + | ```sh |
| + | vi /etc/config/uhttpd |
| + | ``` |
| + | |
| + | 修改 listen 的端口,把 `80` 端口改成 `81`,把 `443` 端口修改 `1443` |
| + | |
| + | 重启 uhttpd |
| + | |
| + | ```sh |
| + | service uhttpd restart |
| + | ``` |
| + | |
| + | ## 安装 nginx |
| + | |
| + | ```sh |
| + | opkg update |
| + | opkg install nginx |
| + | ``` |
| + | |
| + | ## 禁用 uci 配置 nginx |
| + | |
| + | > uci 会根据按 uci 配置,生成 nginx 文件,默认配置会将 http 重定向到 https |
| + | > |
| + | > 这里禁用uci,选择自行编写 nginx 配置 |
| + | |
| + | ```sh |
| + | uci set nginx.global.uci_enable=false |
| + | uci commit nginx |
| + | ``` |
| + | |
| + | ## 添加 nginx 配置文件 |
| + | |
| + | ```sh |
| + | vi /etc/nginx/conf.d/_lan.conf |
| + | ``` |
| + | |
| + | ```conf |
| + | server { |
| + | listen 80; |
| + | server_name _; |
| + | location / { |
| + | proxy_pass http://127.0.0.1:81; |
| + | } |
| + | } |
| + | ``` |
| + | |
| + | ```sh |
| + | service nginx reload |
| + | service nginx restart |
| + | ``` |