ngrok 编译服务器客户端设置

网络 · 2016-05-22 · 663 人浏览

服务端编译需要go1.6+, 下载源码

git clone https://github.com/inconshreveable/ngrok.git ngrok
cd ngrok
生成证书
NGROK_DOMAIN="xxxx.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 base.pem assets/client/tls/ngrokroot.crt
编译, 完成后ngrok和ngrokd位于bin下
sudo make release-server release-client
启动服务器
sudo ./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="xxxx.com" -httpAddr=":8081" -httpsAddr=":8082"
32位或者arm客户端再编译, 位于bin下的Linux_arm下

sudo GOOS=linux GOARCH=arm make release-client
客户端启动, 80端口调试直接运行

./ngrok -config ngrok.cfg -subdomain www2 80
tcp 端口转发
编辑 ngrok.cfg
server_addr: "ngrok.natapp.cn:4443"
trust_host_root_certs: false

tunnels:
  ssh:
    remote_port: 48822
    proto:
      tcp: 22
  web:
    remote_port: 80
    proto:
      tcp: 80
运行

./ngrok -config ngrok.cfg start ssh web

gvm 安装 go

Requirements
sudo apt-get install curl git mercurial make binutils bison gcc build-essential
install
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
install go 1.6.2
gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.6.2
ngrok ubuntu

Buy Me a Coffee

支付宝 支付宝
微信 微信
Theme Jasmine by Kent Liao