1 Installing git and Golang
Apt-get install build-essential Golang mercurial git
2 Download the source, of course, you can not install git, but need to manually upload the code to the desired location.
The unofficial address is used here to fix some packages not available (excerpt from the network)
git clone https://github.com/tutumcloud/ngrok.git Ngrok
3 Generating a self-signed certificate
When using the Ngrok.com official service, we use the official SSL certificate. Self-built NGROKD service, if you do not want to buy an SSL certificate, we need to generate our own self-signed certificate and compile a Ngrok client that carries the certificate.
The certificate generation process requires a ngrok_base_domain. Take Ngrok official randomly generated address xxx.ngrok.com as an example, its ngrok_base_domain is "ngrok.com",
If you want to provide a service with the address "example.ngrok.xxx.com", then Ngrok_base_domain should be "ngrok.xxx.com".
This test, because there is no redundant domain name, I replaced my own two-level domain name "risk001.cn".
CD Ngrok
Ngrok_domain= "risk001.cn"
OpenSSL genrsa-out Base.key 2048
OpenSSL req-new-x509-nodes-key base.key-days 10000-subj "/cn= $NGROK _domain"-out Base.pem
OpenSSL genrsa-out Server.key 2048
OpenSSL req-new-key server.key-subj "/cn= $NGROK _domain"-out SERVER.CSR
OpenSSL x509-req-in server.csr-ca base.pem-cakey base.key-cacreateserial-days 10000-out server.crt
Need to replace certificate when execution is complete
CP Base.pem ASSETS/CLIENT/TLS/NGROKROOT.CRT
Compile
Make Release-server release-client
After successful compilation, the two files of Ngrokd and Ngrok are found in the bin directory. One of the NGROKD is the service-side program.
Start the service side
./bin/ngrokd-tlskey=server.key-tlscrt=server.crt-domain= "risk001.cn"-httpaddr= ":"-httpsAddr= ": 443"
Compiling the Client
(1) Windows
Goos=windows Goarch=amd64 make Release-client