yum -y install gcc golang wget
cd /usr/local/
git clone https://github.com/dollarphper/ngrok.git
cd ngrok/
export NGROK_DOMAIN="dollarphp.com"
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
make release-server
# linux:
GOOS=linux GOARCH=amd64 make release-client
# windows:
GOOS=windows GOARCH=amd64 make release-client
# mac
GOOS=darwin GOARCH=amd64 make release-client
#!/bin/bash
NGROK_DOMAIN=dollarphp.com
function start()
{
/usr/local/ngrok/bin/ngrokd -log="/var/log/ngrok/ngrok.log" -domain="$NGROK_DOMAIN" 1> /dev/null 2> /var/log/ngrok/ngrok.log &
}
function stop()
{
pkill ngrokd
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage : start | stop | restart"
;;
esac
b. 添加可执行权限:
chmod a+x /etc/init.d/ngrokd
c. 刷新系统启动项:
systemctl daemon-reload
d. 创建日志文件:
mkdir -p /var/log/ngrok
touch /var/log/ngrok/ngrok.log
systemctl start ngrokd
scp root@104.225.233.xxx://usr/local/ngrok/bin/ngrok ./
server_addr: "dollarphp.com:4443"
trust_host_root_certs: false
tunnels:
http:
subdomain: "test"
proto:
http: "80"
ssh:
remote_port: 8023
proto:
tcp: "22"
./ngrok -log=ngrok.log -config=ngrok.conf start http ssh
原文地址:http://blog.51cto.com/12173069/2120166