目录
ngrok来做反向代理
介绍
ngrok是做反向代理的神器,之前用的花生壳,但其速度属实有点慢。现在自己买了服务器,可以尝试下ngrok自己搭建代理,其实我在写GitHub的很多开源项目中看到了它的身影。ngrok是用go语言开发的,其作用是将本地服务越过防火墙和NAT(network address transfer)暴露到公网中。
使用
楼主使用ngrok来解决微信订阅号的开发的本地调试,ngrok一次编译可得到linux和windows版本的客户端。服务器系统:centos 7 , 本地系统:Windows 10
- 克隆源码到本地
$ git clone https://github.com/inconshreveable/ngrok.git
- 安装必要的go环境和git
$ yum install build-essential golang mercurial git
- 生成证书
$ export NGROK_DOMAIN="your web domain"
$ openssl genrsa -out rootNG.key 2048
$ openssl req -x509 -new -nodes -key rootNG.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootNG.pem
$ openssl genrsa -out server.key 2048
$ openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
$ openssl x509 -r