在域名购买网站设置域名解析
例如现有域名: example.com
!!!!!!!!! 具体域名换成自己的 !!!!!!!!!
在域名解析新增两条A记录并指向当前服务器
ngrok.example.com
*.ngrok.example.com
10分钟之后尝试 ping ngrok.example.com
如果ping通则代表设置成功
yum install golang
如果没有权限,请使用 sudo 安装,安装完成之后,执行 go version
看到如下信息,证明安装成功:
go version go1.7.3 linux/amd64
设置go环境变量,在 ~/.bash_profile
export GOPATH=$HOME/go
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$GOPATH/bin
保存后,重新加载配置文件 source ~/.bash_profile 执行完成后,echo $GOPATH 可查看go路径 如果git版本小于1.7版本需要自行升级
cd /home
git clone https://github.com/vok123/ngrok.git
cd ngrok
export GOPATH=/home/ngrok
NGROK_DOMAIN="ngrok.example.com"
openssl genrsa -out base.key 2048
openssl req -new -x509 -nodes -key base.key -days 10000 -subj "/CN=$NGROK_DOMAIN" -out base.pem
openssl genrsa -out server.key 2048
openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
openssl x509 -req -in server.csr -CA base.pem -CAkey base.key -CAcreateserial -days 10000 -out server.crt
覆盖文件
cp server.key assets/server/tls/snakeoil.key
cp server.crt assets/server/tls/snakeoil.crt
cp base.pem assets/client/tls/ngrokroot.crt
sudo make release-server
得到服务端 /home/ngrok/bin/ngrokd
linux arm
GOOS=linux GOARCH=arm make release-client
linux 32
GOOS=linux GOARCH=386 make release-client
linux amd64
GOOS=linux GOARCH=amd64 make release-client
windows 32
GOOS=windows GOARCH=386 make release-client
windows 64
GOOS=windows GOARCH=amd64 make release-client
mac 32
GOOS=darwin GOARCH=386 make release-client
mac 64
GOOS=darwin GOARCH=amd64 make release-client
执行完编译客户端指令之后将得到 /home/ngrok/bin/*/ngrok
并将其下载
httpAddr指定监听端口
cd /home/ngrok/bin
nohup ./ngrokd -domain="ngrok.example.com" -httpAddr=":80" &
新建 ngrok.cfg 配置文件 (这里固定4443端口)
server_addr: “ngrok.example.com:4443"
trust_host_root_certs: false
运行客户端,暴露本地8080端口, 控制台执行:
ngrok -subdomain test -config=./ngrok.cfg 8080
-subdomain 指令指定自定义域名 -subdomain test => test.ngrok.example.com
Tunnel Status online
Version 1.7/1.7
Forwarding http://test.ngrok.example.com -> 127.0.0.1:8080
Forwarding https://test.ngrok.example.com -> 127.0.0.1:8080
Web Interface 127.0.0.1:4040
Tunnel Status reconnecting
- 检查服务器是否有启动
ngrokd
服务端程序ps -ef | grep ngrokd
- 检查服务器防火墙是否有限制
ngrokd
- 检查
ngrok.example.com
是否能ping通
ngrok - Introspected tunnels to localhost (homepage)
ngrok is a reverse proxy that creates a secure tunnel from a public endpoint to a locally running web service. ngrok captures and analyzes all traffic over the tunnel for later inspection and replay.
ngrok 2.x is the successor to 1.x and the focus of all current development effort. Its source code is not available.
NOTE This repository contains the code for ngrok 1.x.
ngrok 1.x is no longer developed, supported or maintained by its author, except to ensure that the project continues to compile. The contribution policy has the following guidelines:
- All issues against this repository will be closed unless they demonstrate a crash or other complete failure of ngrok's functionality.
- All issues against this repository are for 1.x only, any issues for 2.x will be closed.
- No new features will be added. Any pull requests with new features will be closed. Please fork the project instead.
- Pull requests fixing existing bugs or improving documentation are welcomed.
ngrok.com ran a pay-what-you-want hosted service of 1.x from early 2013 until April 7, 2016. Afterwards, it only runs 2.x service.
DO NOT RUN THIS VERSION OF NGROK (1.X) IN PRODUCTION. Both the client and server are known to have serious reliability issues including memory and file descriptor leaks as well as crashes. There is also no HA story as the server is a SPOF. You are advised to run 2.0 for any production quality system.
- Expose any http service behind a NAT or firewall to the internet on a subdomain of ngrok.com
- Expose any tcp service behind a NAT or firewall to the internet on a random port of ngrok.com
- Inspect all http requests/responses that are transmitted over the tunnel
- Replay any request that was transmitted over the tunnel
- Temporarily sharing a website that is only running on your development machine
- Demoing an app at a hackathon without deploying
- Developing any services which consume webhooks (HTTP callbacks) by allowing you to replay those requests
- Debugging and understanding any web service by inspecting the HTTP traffic
- Running networked services on machines that are firewalled off from the internet