使用 ngrok 进行内网穿透——2 (如何添加多隧道)

上回讲到ngrok1.7的搭建

使用一段时间后发现有了新的需求

我的内网机器需要添加两个端口

如80和8008端口

那么就需要开启多隧道模式了

首先,服务端无需变动

修改客户端ngrok.cfg

server_addr: ngrok.6le6le.com:4443
trust_host_root_certs: false
#新增多隧道
tunnels:
    tunnel1:
        subdomain: aaa
        proto:
            http: 80
    tunnel2:
        subdomain: bbb
        proto:
            http: 8080

之后使用新的启动命令

./ngrok -config ngrok.cfg start tunnel1 tunnel2

出现如下界面

ngrok                                                                                                                                                   (Ctrl+C to quit)

Tunnel Status                 online
Version                       1.7/1.7
Forwarding                    http://aaa.ngrok.baidu.com:8081 -> 127.0.0.1:80
Forwarding                    http://bbb.ngrok.baidu.com:8081 -> 127.0.0.1:8080
Web Interface                 127.0.0.1:4040
# Conn                        0
Avg Conn Time                 0.00ms

多隧道就已经启动了

访问aaa.ngrok.baidu.com:8081将转发到内网80端口

访问bbb.ngrok.baidu.com:8081将转发到内网8080端口

ps:这两个域名都要提前在网络运营商处做好解析

发布了30 篇原创文章 · 获赞 30 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/guoqian1408/article/details/105729372