环境准备

https://www.digitalocean.com/community/tutorials/how-to-install-go-1-6-on-ubuntu-14-04 https://www.svenbit.com/2014/09/run-ngrok-on-your-own-server/ https://blog.hihuyang.com/?p=17

生成证书

编译客户端

1
~/ngrok# GOOS=windows GOARCH=386 make release-client

生成在bin/windows_386

配置文件

反向代理

1
2
cd etc/nginx/conf.d
vi org.yoyoo.tunnel.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
upstream nodejs {
    server 127.0.0.1:8000;
}
server {
    listen 80;
    server_name *.rp.test.com;
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host  $http_host:8000;
        proxy_set_header X-Nginx-Proxy true;
        proxy_set_header Connection "";
        proxy_pass      http://nodejs;
    }
    error_page   502  /rp502.html;
    location = /rp502.html {
        root   /home/errpages;
    }
}

启动

1
2
cd home/azueruser/ngrok/bin
/home/azueruser/ngrok/bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="tunnel.yoyoo.org" -httpAddr=":8080" -httpsAddr=":8081"