ngrok 搭建脚本

推荐 https://github.com/fatedier/frp 比 ngrok 好用很多


看文档太复杂了,脑子又记不住,先贴这了。

需要的时候改一下DOMAIN 直接跑

参考自:https://aotu.io/notes/2016/02/19/ngrok/

Install

#!/bin/sh

DOMAIN=your-domain.com

cd $GOPATH/src
git clone https://github.com/inconshreveable/ngrok.git
cd ngrok

# 生成 key
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=${DOMAIN}" -days 5000 -out rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -subj "/CN=${DOMAIN}" -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000

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

make release-server
make release-client

Run

Server

bin/ngrokd -domain="${DOMAIN}" -httpAddr=":10080" -httpsAddr=":10443"

Client

cd bin
echo 'server_addr: "'${DOMAIN}':4443"' > ngrok.cfg
echo 'trust_host_root_certs: false' >> ngrok.cfg
./ngrok -subdomain demo -config=ngrok.cfg 8080

你可能感兴趣的:(ngrok 搭建脚本)