# 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 ```