openwrt 使用的是 uHTTPd 提供服务,因为不能添加多个域名监听,所以我将其替换成了 nginx。
在 路由器管理页面上的软件包内选择 luci-nginx 进行安装,安装这包会自动将 uHTTPd 替换成 nginx。过程中可能会有 XHR 报错,不用管,这是这是 uHTTPd 替换为 nginx 过程中重启了,所以网页请求报错了。安装好后刷新页面会跳转到登录页重新登录就好了。
使用 nginx 后 http 请求会重定向到 http,如果不影响你的使用那么现在就安装好了。
我在 openwrt 上放了 iptv 的节目列表,电视盒子上已经设置好了http地址,所以我还需要,关闭 https 重定向启动 http。
登录终端屏蔽 uci ,如果不屏蔽的话,修改 nginx 的配置会被 cui 自动覆盖。
1 | uci set nginx.global.uci_enable=false |
创建 uci 使用的配置是 uci.conf nginx 使用的配置是 nginx.conf,关闭 uci 管理 nignx 就需要创建 nginx.conf 这里我直接使用 nginx 的配置。
1 | cp /etc/nginx/uci.conf /etc/nginx/nginx.conf |
/etc/nginx/nginx.conf 的配置我进行了简单的修改,以启用 80 http。直接复制 https 配置从 server_name 开始到结束的配置,并删除 ssl 部分,覆盖到 http 从 server_name,开始到结束。
下面是我的修改后的结果。
1 | server { #see uci show 'nginx._lan' |
nginx -t 检测配置没有问题后。重启即可
1 | service nginx reload |
下面是我实际使用的配置参考意义不大主要是方便自己,我将使用 ipv6 访问路由器管理页,以及 http 只在内网可以访问
1 | server { |
nginx 配参考 https://openwrt.org/docs/guide-user/services/webserver/nginx
防火墙放行ipv6 参考 https://deeprouter.org/article/openwrt-ipv6-firewall-allow-client-address-port