文档中的命令不要一次执行多个,防止出现不必要的错误
-
安装依赖
yum -y install zlib-devel openssl-devel perl hg cpio expat-devel gettext-devel curl curl-devel perl-ExtUtils-MakeMaker hg wget gcc gcc-c++
-
下载git
cd /tools/
wget https://www.kernel.org/pub/software/scm/git/git-2.6.0.tar.gz
-
解压git
tar -zxvf git-2.6.0.tar.gz
-
编译git
cd git-2.6.0
./configure --prefix=/usr/local/git
make
make install
-
创建git软连接
ln -s /usr/local/git/bin/* /usr/bin/
-
下载go
cd /tools/
wget http://www.golangtc.com/static/go/1.4.2/go1.4.2.linux-386.tar.gz
-
解压go
tar -zxvf go1.4.2.linux-386.tar.gz
mv go /usr/local/
-
建立go软连接
ln -s /usr/local/go/bin/* /usr/bin/
-
获取ngrok
cd /tools
wget https://github.com/inconshreveable/ngrok/archive/1.7.1.zip
tar -zxvf ngrok-1.7.1.tar.gz
mv ngrok-1.7.1 ngrok
mv ngrok /usr/local/src/ngrok/
export GOPATH=/usr/local/src/ngrok/
export NGROK_DOMAIN="域名"
cd ngrok
-
生成证书
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.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 rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 5000
-
拷贝证书
cp rootCA.pem assets/client/tls/ngrokroot.crt
cp server.crt assets/server/tls/snakeoil.crt
cp server.key assets/server/tls/snakeoil.key
-
国内服务器需要执行此修改操作
vim /usr/local/src/ngrok/src/ngrok/log/logger.go
log "github.com/keepeye/log4go"
-
编译服务端
cd /usr/local/go/src
GOOS=linux GOARCH=amd64 ./make.bash
cd /usr/local/src/ngrok/
GOOS=linux GOARCH=amd64 make release-server
-
编译mac 客户端
cd /usr/local/go/src
GOOS=darwin GOARCH=amd64 ./make.bash
cd /usr/local/src/ngrok/
GOOS=darwin GOARCH=amd64 make release-client
-
编译windows 客户端
cd /usr/local/go/src
GOOS=windows GOARCH=amd64 ./make.bash
cd /usr/local/src/ngrok/
GOOS=windows GOARCH=amd64 make release-client
-
编译linux 客户端
cd /usr/local/go/src
GOOS=linux GOARCH=amd64 ./make.bash
cd /usr/local/src/ngrok/
GOOS=linux GOARCH=amd64 make release-client
-
启动服务
/usr/local/src/ngrok/bin/ngrokd -domain="$NGROK_DOMAIN" -httpAddr=":80"
-
客户端配置文件 ngrok.cfg
server_addr: "域名:4443"
trust_host_root_certs: false
-
客户端使用
./ngrok -config=./ngrok.cfg -subdomain=blog 80
setsid ./ngrok -config=./ngrok.cfg -subdomain=test 80 #在linux下如果想后台运行
原文中有问题,已做修改。