Openwrt 修改Web页面默认访问端口

 

openwrt如何简单隐藏Web页面

  • 路由器刷入openwrt并且启用了Web页面(一般是Luci),将路由任一LAN口与电脑连接(IP自动获取),一般只需要浏览器输入LAN口的IP地址后就可以访问路由器的Web页面,如浏览器打开后直接输入:192.168.1.1
  • 浏览器http默认为80端口,故实际访问为:http://192.168.1.1:80/
  • 如果修改了openwrt默认的http监听端口号80,那么就不能直接输入:192.168.1.1来访问Web页面,如将默认监听端口修改为8080,则需要输入IP的同时制定端口号才能正确访问openwrt的Web页面,如:http://192.168.1.1:8080/
  • 这样修改了默认监听端口号后,就可以一定程度的隐藏web端,不让普通用户访问(当然还可设置web访问密码);需要修改配置的时候管理员依然可以使用Web页面去配置路由。

80端口是为HTTP(HyperText Transport Protocol)即超文本传输协议开放的,此为上网冲浪使用次数最多的协议,主要用于WWW(World Wide Web)即万维网传输信息的协议。

可以通过HTTP地址(即常说的“网址”)加“: 80”来访问网站,因为浏览网页服务默认的端口号都是80,因此只需输入网址即可,不用输入“: 80”了。

Openwrt 修改Web页面默认访问端口大致步骤如下:

  1. 使用​​​​串口或者SSH登录openwrt后台;
  2. openwrt 中默认使用的web服务器是uhttpd,
  3. 进入配置文件路径:cd etc/config/
  4.  使用vim编辑器修改uhttpd文件 vi uhttpd 

使用串口连接电脑后进入openwrt

BusyBox v1.28.3 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 18.06-SNAPSHOT, r7201-4f3082583a
 -----------------------------------------------------
root@OpenWrt:/# 

vim编辑器打开uhttpd 文件

# Server configuration
config uhttpd main

        # HTTP listen addresses, multiple allowed
        list listen_http        0.0.0.0:80
        list listen_http        [::]:80

        # HTTPS listen addresses, multiple allowed
        list listen_https       0.0.0.0:443
        list listen_https       [::]:443

        # Redirect HTTP requests to HTTPS if possible
        option redirect_https   1

        # Server document root
        option home             /www

        # Reject requests from RFC1918 IP addresses
        # directed to the servers public IP(s).
        # This is a DNS rebinding countermeasure.
        option rfc1918_filter 1

        # Maximum number of concurrent requests.
        # If this number is exceeded, further requests are
        # queued until the number of running requests drops
        # below the limit again.
        option max_requests 3

        # Maximum number of concurrent connections.
        # If this number is exceeded, further TCP connection
        # attempts are queued until the number of active
        # connections drops below the limit again.
        option max_connections 100

        # Certificate and private key for HTTPS.
        # If no listen_https addresses are given,
        # the key options are ignored.
        option cert             /etc/uhttpd.crt
        option key              /etc/uhttpd.key

        # CGI url prefix, will be searched in docroot.
        # Default is /cgi-bin
        option cgi_prefix       /cgi-bin

        # List of extension->interpreter mappings.
        # Files with an associated interpreter can
        # be called outside of the CGI prefix and do
        # not need to be executable.


  • 修改完成后保存(:wq)
  • 重启uhttpd(或重启路由器root@OpenWrt:/# etc/init.d/uhttpd restart(# reboot)
  • 使用新的端口登录web端,如:http://192.168.1.1:8080/

另外,openwrt的官网有说明,默认情况下uHTTPd绑定的端口也包含WAN口,如果要指定只包含LAN口的话可以按照下图步骤设置。

 

By default, uHTTPd is bind to 0.0.0.0 which also includes the WAN port of your router. To bind uHTTPd to the LAN port only you have to change the listen_http and listen_https options to your LAN IP address.

To get your current LAN IP address run this command:

# uci get network.lan.ipaddr
192.168.1.1

Then edit /etc/config/uhttpd and bind listen_http to specific 192.168.1.1 IP instead of 0.0.0.0 and comment out IPv6 bindings:

config uhttpd main
        # HTTP listen addresses, multiple allowed
        list listen_http        192.168.1.1:80
#       list listen_http        [::]:80
 
        # HTTPS listen addresses, multiple allowed
        list listen_https       192.168.1.1:443
#       list listen_https       [::]:443
  • 1
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值