Instantly share code, notes, and snippets.

@popucui popucui/ngrok v1 setup
Last active Jul 6, 2018

Embed
What would you like to do?
# refer to this doc for instruction about compiling the ngrok server/client binary
https://imququ.com/post/self-hosted-ngrokd.html
# step1_prepare_crt.bash, run this in ngrok directory
export NGROK_DOMAIN="yourdomain.com"
/usr/bin/openssl genrsa -out base.key 2048 -config ./openssl.cnf
/usr/bin/openssl req -new -x509 -nodes -key base.key -days 10000 -subj "/CN=$NGROK_DOMAIN" -out base.pem -config ./openssl.cnf
/usr/bin/openssl genrsa -out server.key 2048 -config ./openssl.cnf
/usr/bin/openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr -config ./openssl.cnf
/usr/bin/openssl x509 -req -in server.csr -CA base.pem -CAkey base.key -CAcreateserial -days 10000 -out server.crt
cp base.pem assets/client/tls/ngrokroot.crt
# step2_compile.bash
# for linux
# see https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 for full list
GOOS="linux"
GOARCH="amd64"
make release-server release-client
# for Mac os X
GOOS="darwin"
GOARCH="amd64"
make release-server release-client
#fire up the ngrok daemon service on server
./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="yourdomain.com" -httpAddr=":8081" -httpsAddr=":8088"
## ngrok.cfg in the $PWD
server_addr: yourdomain.com:4443
trust_host_root_certs: false
# start ngrok client-side service on client
./ngrok -config=ngrok.cfg start ssh
## ngrok.cfg in the $PWD
server_addr: yourdomain.com:4443
trust_host_root_certs: false
tunnels:
ssh:
remote_port: 36523
proto:
tcp: 22
## Note you just need to specify different remote_port for different clients while using the same server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment