This is a creation in Article, where the information may have evolved or changed.
Overview
Why build your own Ngrok service? The reason is very simple, the official if the binding domain name to charge Ah, own server, so they build a good, the server configuration is not high, said the actual Raspberry Pi io really miserable, my system installed in the U disk or Kaka card
Anyway, just throw the Raspberry Pi on the public network.
Build Ngork Service
First of course to install go, because Ngrok use go write, but Go official website is wall, so you have to learn science online, because my server is foreign, so there is no such network problems.
First download Go
wget https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
Extract
tar -zxvf go1.9.1.linux-amd64.tar.gz
Then move the extracted folder to your favorite location, the general source code installed software I like to put under the/usr/local, so I put go there
mv go /usr/local
The commands in the Go Bin directory are then soft-wired to the/usr/bin so that no environment variables are configured
Then test whether it is successful, enter
go env
Then install Ngrok
First clone under source code
git clone https://github.com/inconshreveable/ngrok.git
Generate a self-signed certificate
Create a new folder
mkdir SSL
Set a variable to save your domain name, use this variable name when generating the certificate instead of modifying
export ngrok_domain= Ngrok.bboysoul.com "
Next line copy the following command execution
OpenSSL genrsa-out rootca.key 2048
OpenSSL Req-new-x509-nodes-key base.key-days 10000-subj "/cn= $NGROK _domain"-out base.pem
OpenSSL Genrsa-ou T Server.key 2048
OpenSSL req-new-key server.key-subj "/cn= $NGROK _domain"-out SERVER.CSR
Code>openssl x509-req-in server.csr-ca base.pem-cakey base.key-cacreateserial-days 10000-out server.crt
You will find 6 more files in your current folder
replace them with Ngrok original certificate
CP Base.pem. /assets/client/tls/ngrokroot.crt-i
CP server.crt. /assets/server/tls/snakeoil.crt-i
CP Server.key. /assets/server/tls/snakeoil.key-i
After that, the service side is compiled
Because mine is the AMD64 bit system, so set the environment variable
export GOOS=linux
export GOARCH=386
Next make
make release-server
Then compile the client, because my Raspberry Pi is arm, so modify the environment variable
export GOARCH=arm
make release-client
DNS settings
There are two resolution settings for the domain name
One is *.ngrok.
One is Ngrok.
Deployment
Put the compiled Ngrok server into the/usr/bin
cp bin/linux_386/ngrokd /usr/bin
Run
Create a new session
screen -S ngrok
Run
sudo ngrokd -domain="ngrok.bboysoul.com" -httpAddr=":8080" -httpsAddr=":443"
Client deployment
First put
scp root@ngrok.bboysoul.com:/root/software/ngrok/ngrok/bin/linux_arm/ngrok /home/bboysoul
Copy to Raspberry Pi
Touch a configuration file, such as
touch ngrok.cfg
Enter it on the inside
server_addr: ngrok.bboysoul.com:4443
trust_host_root_certs: false
Domain name Modify it yourself
Then open a virtual reply
screen -S ngrok
./ngrok -subdomain pi -proto=http -config=ngrok.cfg 8080
Parameter explanation subdomain is your designated level four domain name, HTTP is HTTP protocol 8080 is the port,-config is followed by your profile name, and then if you see
Tunnel Status online
This means that the connection succeeds, if not successful, check the firewall, the port is not open.
Welcome to Bboysoul's blog www.bboysoul.com
Has fun