问题解决:
--环境--
windows下
请在C:\Windows\System32\drivers\etc\hosts下加入(如果没有修改权限请自行添加文件修改的权限)
49.xxx.xxx.xxx domain2.domain1.domain0
49.xxx.xxx.xxx subdomain.domain2.domain1.domain0
linux
请在/etc/hosts下加入
49.xxx.xxx.xxx domain2.domain1.domain0
49.xxx.xxx.xxx subdomain.domain2.domain1.domain0
ps:
可以参照https://github.com/inconshreveable/ngrok/blob/master/docs/DEVELOPMENT.md
建议1.7包括以后版本使用yml来配置ngrok如下(yml请使用space,不是table):
server_addr: domain2.domain1.domain0:4443 #tunnel端口为4443
tunnels:
httpTunnelName: #执行脚本中要执行的映射,将http://XXX.domain2.domain1.domain映射到localhost:8013端口上
proto:
http: 8013
subdomain: XXX
并且使用nginx来配置反向代理,如下
server {
# http 通过8082映射80端口
listen 80;
server_name tunnel.hteen.cn *.tunnel.hteen.cn;location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxx.xxx.xxx.xxx:8082;
}}
server {
# https 通过8082映射80端口
listen 443;
server_name tunnel.hteen.cn *.tunnel.hteen.cn;location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxx.xxx.xxx.xxx:4432;
}}
windows客户端新建一个.bat文件,并写入
ngrok.exe -config ngrok.yml -log=ngrok.log start httpTunnelName #建议输出log,这样能够更好的判断错误
以上,有错误的地方还请指正~