openwrt修改后台访问端口及开启https
修改后台访问端口:
需要修改openwrt的配置文件,文件路径 /etc/config/uhttpd
uhttpd文件内容如下,按需修改红色字体内容
config uhttpd 'main' list listen_http '0.0.0.0:80' #ipv4 http监听端口 list listen_http '[::]:80' #ipv6 http监听端口 list listen_https '0.0.0.0:443' #ipv4 https监听端口 list listen_https '[::]:443' #ipv6 https监听端口 option redirect_https '0' #将http访问强制跳转至https,0---不跳转,1---强制跳转 option home '/www' option rfc1918_filter '1' option max_connections '100' option cert '/etc/uhttpd.crt' #ssl证书路径 option key '/etc/uhttpd.key' #ssl证书路径 option cgi_prefix '/cgi-bin' list lua_prefix '/cgi-bin/luci=/usr/lib/lua/luci/sgi/uhttpd.lua' option network_timeout '30' option http_keepalive '20' option tcp_keepalive '1' option ubus_prefix '/ubus' list index_page 'cgi-bin/luci' option max_requests '50' option script_timeout '3600' config cert 'defaults' option days '730' option key_type 'ec' option bits '2048' option ec_curve 'P-256' option country 'ZZ' option state 'Somewhere' option location 'Unknown' option commonname 'OpenWrt'
使用 vi uhttpd 编辑配置文件,端口自己按需修改,改完访问的话记得加上端口号
list listen_http '0.0.0.0:80' #ipv4http端口80 list listen_http '[::]:80' #ipv6http端口80 list listen_https '0.0.0.0:443' #ipv4https端口443 list listen_https '[::]:443' #ipv6https端口443
开启https访问
首先上传域名证书,比如上传上/etc/config/
目录
vi uhttpd 编辑此处证书指向路径
option cert '/etc/config/uhttpd.crt' option key '/etc/config/uhttpd.key'
最后,重启uhttpd服务
/etc/init.d/uhttpd restart