openwrt 的nginx
简介:
openwrt内部使用 uHTTPd来进行web服务,轻量,简单。
但是有一些静态页面,能否也放进openwrt来跑呢?
nginx由于性能和内存处理等方面的优势,也是可以在openwrt上运行的。
那就在openwrt上用nginx替代 uHTTPd,来提供web服务吧。
一:将luci放进nginx
https://openwrt.org/docs/guide-user/luci/luci.essentials#configuration
LuCI on nginx
For 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目录
六:继续添加两个新项目
订阅转换,订阅模板