目录

[TOC]


一、前言

openwrt中,使用其他反向代理工具时,会发现80和443已被占用,排查发现是uhttpd占用了端口,修改了uhttpd的默认端口以后发现80,443还是被占用,nginx又跳出来了,再次修改nginx的默认端口后,发现80,443已经解除了占用状态,可以给自己的反向代理代理工具使用。

二、修改uhttpd默认端口

vim /etc/config/uhttpd

我把80改成了88,443改成了8443

config uhttpd 'main'
    list listen_https '0.0.0.0:8443'
    list listen_https '[::]:8443'
    option redirect_https '0' 
    option home '/www'
    option rfc1918_filter '1' 
    option max_connections '100'
    option cert '/etc/uhttpd.crt'
    option key '/etc/uhttpd.key'
    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'
    option script_timeout '3600'
    list index_page 'cgi-bin/luci'
    option max_requests '50'
    list listen_http '0.0.0.0:88'
    list listen_http '[::]:88'

config cert 'defaults'
    option days '730'
    option key_type 'ec'

修改完成后重启服务:

/etc/init.d/uhttpd restart

三、修改nginx默认端口

vim /etc/config/nginx

我没有和默认的一样,让uhttpdnginx的默认端口相同,另外设置了个,反正也用不到。

config main global
    option uci_enable 'true'

config server '_lan'
    list listen '12443 ssl default_server'
    list listen '[::]:12443 ssl default_server'
    option server_name '_lan'
    list include 'restrict_locally'
    list include 'conf.d/*.locations'
    option uci_manage_ssl 'self-signed'
    option ssl_certificate '/etc/nginx/conf.d/_lan.crt'
    option ssl_certificate_key '/etc/nginx/conf.d/_lan.key'
    option ssl_session_cache 'shared:SSL:32k'
    option ssl_session_timeout '64m'
    option access_log 'off; # logd openwrt'

config server '_redirect2ssl'
    list listen '1280'
    list listen '[::]:1280'
    option server_name '_redirect2ssl'
    option return '302 https://$host$request_uri'

修改完成后重启服务:

/etc/init.d/nginx restart
Last modification:April 1, 2023
V50%看看实力