Replaces the following ngrok. Getcharzp. Cn to buy their own domain name, and completes the corresponding resolution, relevant video tutorial: www.bilibili.com/video/BV1ZU…

Build with Docker

Prepare:

Domain name + Public network server (centos), map the record value of domain name A to the IP address of public network server, ngrok, *.ngrok

Reference: hub.docker.com/r/jueying/n…

Run the following command on the server

docker run -d --name ngrok-server -p 80:80 -p 8082:8082 -p 443:443 jueying/ngrok-server ngrok.getcharzp.cn 80 8082 443 
Copy the code

Copy the client of the corresponding operating system from ngrok-server (PS: copy the client and go to the corresponding /home/ngrok/bin directory to check whether the windows_amd64 directory has been successfully generated. If not, please wait and copy again later)

docker cp ngrok-server:/usr/local/ngrok/bin/ /home/ngrok 
Copy the code

Go to the /home/ngrok/bin/windows_amd64 directory and copy the generated nginx.exe executable file to the local PC. Create an ngrok. CFG file in the same directory as nginx.exe

server_addr: "ngrok.getcharzp.cn:443"
trust_host_root_certs: false
Copy the code

Create an ngrok.bat file in the same directory as nginx.exe

ngrok.exe -subdomain=test -config=ngrok.cfg 80 
Copy the code

Double-click the ngrok.bat file. If Tunnel Status online is displayed, the configuration is successful.

Compile using source files

Domain name + Public Network Server (centos)

Golang is currently using version 1.14.15

Go Version Go1.14.15 Install Linux/AMD64

CD/root wget tar - C/root - XZF at https://storage.googleapis.com/golang/go1.14.15.linux-amd64.tar.gz Go1.14.15. Linux - amd64. Tar. GzCopy the code

/etc/profile edit file

Vim /etc/profile # add export GOROOT=/root/go export PATH=$PATH:$GOROOT/bin source /etc/profileCopy the code

Download source files

git clone https://github.com/inconshreveable/ngrok.git 
Copy the code

Create a directory for storing keys

cd ngrok && mkdir keys && cd keys
Copy the code

Set the domain name to be mapped

export NGROK_DOMAIN="ngrok.getcharzp.cn"
Copy the code

Generating related certificates

openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000 
Copy the code

Replace the generated certificate

cp rootCA.pem .. /assets/client/tls/ngrokroot.crt cp device.crt .. /assets/server/tls/snakeoil.crt cp device.key .. /assets/server/tls/snakeoil.keyCopy the code

Use domestic mirror image

git clone -- https://gitee.com/mirrors/log4go.git src/github.com/alecthomas/log4go
git clone -- https://gitee.com/ngrok-install/websocket.git src/github.com/gorilla/websocket
git clone -- https://gitee.com/ngrok-install/go-vhost.git src/github.com/inconshreveable/go-vhost
git clone -- https://gitee.com/ngrok-install/mousetrap.git src/github.com/inconshreveable/mousetrap
git clone -- https://gitee.com/ngrok-install/go-bindata.git src/github.com/jteeuwen/go-bindata
git clone -- https://gitee.com/mirrors_addons/osext.git src/github.com/kardianos/osext
git clone -- https://gitee.com/ngrok-install/binarydist.git src/github.com/kr/binarydist
git clone -- https://gitee.com/GoLibs/go-runewidth.git src/github.com/mattn/go-runewidth
git clone -- https://gitee.com/ngrok-install/termbox-go.git src/github.com/nsf/termbox-go
git clone -- https://gitee.com/mirrors/go-metrics.git src/github.com/rcrowley/go-metrics 
Copy the code

Go to the root directory of ngrok and select the corresponding server and client to compile

cd .. GOOS= Linux GOARCH=386 make relex-server (32-bit) GOOS= Linux GOARCH=386 make relex-server (64-bit Make release-client (32-bit) GOOS= Linux GOARCH=386 make release-client (64-bit) #Mac OS server GOOS= Darwin Make release-server GOOS= Darwin GOARCH=amd64 make release-server #Mac OS client GOOS= Darwin GOARCH=386 make Release -client GOOS= Darwin GOARCH=amd64 make release-client # Windows server GOOS= Windows GOARCH=386 make release-server GOOS= Windows GOARCH=amd64 make releve-server # Windows GOARCH=386 make releve-client GOOS= Windows GOARCH=amd64 make release-clientCopy the code

Go to the bin directory of the current directory to start the server

./ngrokd -domain="ngrok.getcharzp.cn" -httpAddr=":80" 
Copy the code

Go to windows_amd64 and download ngrok.exe, depending on the client platform

Create ngrok. CFG in the same directory as local ngrok.exe

server_addr: “ngrok.getcharzp.cn:4443” trust_host_root_certs: false

Create ngrok.bat in the ngrok.exe directory on the local PC

ngrok.exe -config=ngrok.cfg -subdomain=test 80
Copy the code

Double-click the ngrok.bat file to run it.