openwrt 的nginx | 您所在的位置:网站首页 › nginx关闭ipv6博客园 › openwrt 的nginx |
简介:
openwrt内部使用 uHTTPd来进行web服务,轻量,简单。 但是有一些静态页面,能否也放进openwrt来跑呢? nginx由于性能和内存处理等方面的优势,也是可以在openwrt上运行的。 那就在openwrt上用nginx替代 uHTTPd,来提供web服务吧。 一:将luci放进nginxhttps://openwrt.org/docs/guide-user/luci/luci.essentials#configuration LuCI on nginxFor routers without significant space constraints running on snapshots/master or v19 or later, it is possible to install using nginx. LuCI on nginx is currently supported by using uwsgi as plain-cgi interpreter. You need to install one of this 2 variants of the LuCI meta-package: luci-nginx - Autoinstall nginx, uwsgi-cgi and the default config file to make luci work on nginx. luci-ssl-nginx - Autoinstall nginx-ssl, uwsgi-cgi and the default config file to make luci wok on nginx.看来已经有自动化的包来实现了,也可以带SSL。 opkg update && opkg install ****即可 二:验证系统-启动项 uhttpd已经禁用了 nginx已启动 可以确认已经安装好了 三:查找nginx配置文件linux就这点不好,配置文件到处丢,不同的版本编译出来,配置文件位置也不同。 nginx -t -c /etc/nginx/uci.conf #测试配置文件 nginx -T -c /etc/nginx/uci.conf #详细测试配置文件
具体看配置文件当中有 include conf.d/*.conf; 那么我们就自己新建配置文件吧 四:新建端口监听先搞用端口的,有空再搞按域名的。 /etc/nginx/conf.d 目录下新建subweb.conf 内容如下: server { listen 10088; listen [::]:10088; } /etc/init.d/nginx reload #重新读取配置 /etc/init.d/nginx restart #重启nginx服务 netstat -anutp |grep 10088 #查看10088端口监听
端口已经监听了 五:完整配置 server { listen 10088; listen [::]:10088; server_name _; charset utf-8; location / { root /storage/data/share; index index.html; autoindex on; autoindex_exact_size off; autoindex_localtime on; add_header Cache-Control no-store; } }
这个是配置文件浏览/storage/data/share目录 六:继续添加两个新项目订阅转换,订阅模板 八:特殊端口虽然你可以开放10080端口,但是现在的主流浏览器都默认禁止访问10080端口了。 IPV4的80 443 1080 运营商都封过了。 九:nginx默认白名单/etc/nginx/restrict_locally 这个文件是nginx的默认白名单,出现403错误的时候,记得配一下吧。 allow ::1; allow fc00::/7; allow fec0::/10; allow fe80::/10; allow 127.0.0.0/8; allow 10.0.0.0/8; allow 172.16.0.0/12; allow 192.168.0.0/16; allow 169.254.0.0/16; allow 2408::/10; #我加的 allow 2409::/10; #我加的 allow 240e::/10; #我加的 deny all;
十:openwrt防火墙 记得打开openwrt的防火墙,自己创建规则,允许WAN访问这个端口,否则外部无法访问。
|
CopyRight 2018-2019 实验室设备网 版权所有 |