CentOS7 安装 ngrok

📅 5月9日 / 🎨 开发日志 / 👓 14


内网穿透神器使用记录。

一、安装编译

更新一些基础环境

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

安装 Golang

yum install golang

下载 ngrok 源码

mkdir ngrok
cd ngrok # /home/ngrok
git clone https://github.com/inconshreveable/ngrok.git

生成证书

mkdir cert
cd cert # /home/ngrok/cert
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=ngrok.juexe.cn" -days 5000 -out rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -subj "/CN=ngrok.juexe.cn" -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000

覆盖证书

yes|cp rootCA.pem ../ngrok/assets/client/tls/ngrokroot.crt
yes|cp device.crt ../ngrok/assets/server/tls/snakeoil.crt
yes|cp device.key ../ngrok/assets/server/tls/snakeoil.key

编译生成

go env //查看环境
cd ../ngrok # /home/ngrok/ngrok
GOOS=linux GOARCH=amd64 make release-server

二、运行

测试

./bin/ngrokd -tlsKey="assets/server/tls/snakeoil.key" -tlsCrt="assets/server/tls/snakeoil.crt" -domain="ngrok.juexe.cn"  -httpAddr=":8081" -httpsAddr=":8082" -tunnelAddr=":8083"

后台运行

cd /ngrok/ngrok
setsid ./bin/ngrokd -tlsKey="assets/server/tls/snakeoil.key" -tlsCrt="assets/server/tls/snakeoil.crt" -domain="ngrok.juexe.cn"  -httpAddr=":8081" -httpsAddr=":8082" -tunnelAddr=":8083"

2019-09-10T13:23:11.png

(完)

留言(0)