Reprint: http://www.haiyun.me/archives/1012.html
First install the GO environment, http://www.haiyun.me/archives/1009.html
| 1234 |
cd/usr/local/src/git clone https://github.com/inconshreveable/ngrok.gitexport GOPATH=/usr/local/src/ngrok/exportNGROK_DOMAIN="haiyun.me" |
Generate a self-signed SSL certificate, Ngrok SSL Encrypted connection:
| 123456789101112 |
cd ngrokopenssl genrsa -out rootCA.key 2048openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pemopenssl genrsa -out device.key 2048openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csropenssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000cp rootCA.pem assets/client/tls/ngrokroot.crtcp device.crt assets/server/tls/snakeoil.crt cp device.key assets/server/tls/snakeoil.keyGOOS=linux GOARCH=386make cleanmake release-server release-client |
If you stay in Go get gopkg.in/yaml.v1 reference: https://www.haiyun.me/archives/1011.html
Start server:
| 1 |
bin/ngrokd-domain="$NGROK_DOMAIN"-httpAddr=":8000" |
Cross-compiling the Windows client, it is best to install the latest version of Golang, using the Yum installation has been compiled does not pass.
| 1234 |
cd/usr/local/go/src/GOOS=windows GOARCH=386 CGO_ENABLED=0 ./make.bashcd -GOOS=windows GOARCH=386 makerelease-server release-client |
Client Configuration:
| 12345678910111213 |
server_addr: "haiyun.me:4443"trust_host_root_certs: falsetunnels: http: subdomain: "example" auth: "user:12345" proto: http: "80" ssh: remote_port: 2222 proto: tcp: "22" |
To start the client:
| 1 |
bin/ngrok-config ngrok.conf start http ssh |
Note that all domain must be consistent, or a certificate error will occur:
| 1 |
Failed to read message: remote error: bad certificate |
Self-compiling Ngrok server