Skip to content

Instantly share code, notes, and snippets.

@wbcyclist
Forked from lyoshenka/ngrok-selfhosting-setup.md
Created December 26, 2015 10:53
Show Gist options
  • Save wbcyclist/40eb5becdc8fcbb7c243 to your computer and use it in GitHub Desktop.
Save wbcyclist/40eb5becdc8fcbb7c243 to your computer and use it in GitHub Desktop.
How to setup Ngrok with a self-signed SSL cert

Note: make sure you set the Common Name on the SSL certs to sub.domain.com, not the wildcard *.sub.domain.com.

export NGROK_DOMAIN="my.domain.com"
git clone https://github.com/inconshreveable/ngrok.git
cd ngrok

openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/C=US/ST=NY/L=/O=IT/CN=$NGROK_DOMAIN" -days 1024 -out rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -subj "/C=US/ST=NY/L=/O=IT/CN=$NGROK_DOMAIN" -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 500

mv rootCA.pem assets/client/tls/ngrokroot.crt
make clean
make release-server
make release-client

# copy bin/ngrok to client

# on server
bin/ngrokd -tlsKey=device.key -tlsCrt=device.crt -domain="$NGROK_DOMAIN" -httpAddr="" -httpsAddr=""

#on client
echo -e "server_addr: $NGROK_DOMAIN:4443\ntrust_host_root_certs: false" > ngrok-config
./ngrok -config=ngrok-config -proto=tcp 22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment