Ngrok 内网穿透(NAT)服务器搭建, No such host is know解决方法

问题解决:

--环境--

   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,这样能够更好的判断错误

以上,有错误的地方还请指正~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值