微信开发:NAT穿透

原帖收藏于IT老兵博客html

微信开发:NAT穿透。web

前言

调试微信,遇到问题,微信没法直接通知到开发机上,而是须要一台服务器的地址上,这给调试增长了难度,上网研究了一下,若是在windows下,能够使用花生壳软件,进行NAT穿透,可是花生壳不支持mac,又找了找,发现了ngrok,这个配置很简单,解决了问题。windows

正文

一共须要四步:浏览器

Download ngrok
First, download the ngrok client, a single binary with zero run-time dependencies.
Mac OS XWindows Linux Mac (32-bit) Windows (32-bit)Linux (ARM) Linux (ARM64) Linux (32-bit)FreeBSD (64-Bit) FreeBSD (32-bit)tomcat

第一步,下载ngrok,它支持Mac、Linux、Windows等多个操做系统。服务器

Unzip to install
On Linux or OSX you can unzip ngrok from a terminal with the following command. On Windows, just double click ngrok.zip.
unzip /path/to/ngrok.zip
Most people like to keep ngrok in their primary user folder or set an alias for easy command-line access.微信

第二步,解压缩。微信开发

Connect your account
Running this command will add your authtoken to your ngrok.yml file. Connecting an account will list your open tunnels in the dashboard, give you longer tunnel timeouts, and more. Visit the dashboard to get your auth token.ide

./ngrok authtoken <YOUR_AUTH_TOKEN>

Don’t have an account?
Sign up for free to get your auth token.svg

第三步,注册帐号,点击上面的Sign up连接,去注册,或者使用谷歌帐户受权,有了受权,这个工具会提供更好的支持。

Fire it up
Try it out by running it from the command line:
./ngrok help
To start a HTTP tunnel on port 80, run this next:
./ngrok http 80
Read the documentation to get more ideas on how to use ngrok.

第四部,开始使用,./ngrok help 能够获取帮助,./ngrok http 80 开始运行,注意80是你想要反向代理的端口,这个要根据你的需求来设置,例如这里是tomcat,端口是8080,那么上面要改为8080。

在这里插入图片描述

运行起来以后,它会给你分配一个动态的域名,如上图,在浏览器访问这个域名,就能够访问到你的服务了。

总结

工欲善其事,必先利其器。微信开发,若是不配置好这个回调,那么每次都须要部署到服务器上才能验证,这样效率会低不少。

相关文章
相关标签/搜索