基于ngrok实现natapp内网NAT穿透与反向代理 本文为旧博客 迁移的文章
使用到的工具:natapp.cn
前期准备 在控制台获得一个16位的authtoken写入以下内容(替换authtoken)
1 2 3 4 5 6 7 8 9 [default] authtoken =************* clienttoken = log =none loglevel =ERROR http_proxy =
osx用户需要给权限
运行 natapp,控制台返回
1 2 3 4 5 6 Powered By NATAPP Please visit https: Tunnel Status Online Version 2.3 .8 Forwarding http: Web Interface http: Total Connections 0
得到类似上面的证明运行成功。
试试访问http://*****.natappfree.cc
配置失败应该返回的是:
1 Tunnel ancasc .natappfree .cc not found
配置Apache开启多域名支持
OSX系统中XMAPP默认的配置文件是/Applications/XAMPP/xamppfiles/etc/httpd.conf
, 可以找到Include etc/extra/httpd-vhosts.conf
打开/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
文件 修改VirtualHost
文件
1 2 3 4 5 <VirtualHost *:4001> DocumentRoot "/private/var/www/xxx" ServerName http://natappfree.cc:4001 ServerAlias http://*.natappfree.cc:4001</VirtualHost>
1 2 3 4 5 6 7 8 9 10 Listen 4001 <VirtualHost *:4001 > ProxyPreserveHost On ServerName http:// natappfree.cc:4001 ServerAlias http:// *.natappfree.cc:4001 ProxyPass / http:/ /localhost:9501/ ProxyPassReverse / http:/ /localhost:9501/ </VirtualHost>
上面两个二选一 然后再次访问http://*****.natappfree.cc
,页面就展示出来了。
【出现问题的调试方法】 首先要确定本地服务器是否能正常运行,可以通过设置Hosts的方法来确定问题。
1 127.0.0.1 http://*****.natappfree.cc
welcome to https://iwwee.com