ngrok

服务端安装:

1
2
3
4
5
6
7
8
9
10
11
wget https://raw.githubusercontent.com/oqyj/ngrok/master/ngrok.sh

chmod +x ngrok.sh

sh ./ngrok.sh

默认安装路径
git:/usr/local/git
go:/usr/local/go
ngrok:/usr/local/ngrok
#客户端编译好存放的路径: /usr/local/ngrok/bin/

安装1.4之后的go需要用go1.4编译安装:

>>>的区别,>清空指定文件后添加,>>是在原文件内容基础上追加

用户目录下的.profile是对当前用户永久有效的环境变量,/etc/profile对所有用户永久有效的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ echo "export GOROOT=$HOME/.golang/go" >> ~/.bash_profile
$ echo "export GOPATH=$HOME/.golang/path" >> ~/.bash_profile
$ echo "export PATH=$PATH:$HOME/.golang/go/bin" >> ~/.bash_profile
$ echo "export GOROOT_BOOTSTRAP=$HOME/.golang/go1.4" >> ~/.bash_profile
$ source ~/.bash_profile
$ cd ~
$ mkdir .golang
$ git clone https://github.com/golang/go.git go
$ cp -r go go1.4
$ cd go1.4
$ git checkout -b release-branch.go1.4 origin/release-branch.go1.4
$ cd src
$ ./make.bash
$ cd ../../go
$ git checkout -b release-branch.go1.8 origin/release-branch.go1.8
$ cd src
$ ./make.bash
$ go version

启动服务端:

1
setsid  /usr/local/ngrok/bin/ngrokd -domain=getqyj.gq -httpAddr=":800"

客户端:

生成客户端:

1
2
3
4
cd /usr/local/go/src
GOOS=windows GOARCH=amd64 ./make.bash
cd /usr/local/ngrok/
GOOS=windows GOARCH=amd64 make release-client

完成后把ngrok/bin/windows_amd64文件夹下的ngrok.exe下载下执行即可:

使用客户端:

1
ngrok.exe -config=ngrok.cfg -subdomain=r  8080

访问:
http://r.getqyj.gq:800/ ==> http://localhost:8080