ngrok编译和安装
生活随笔
收集整理的這篇文章主要介紹了
ngrok编译和安装
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1:安裝git
[root@iZuf6h59snssqyqa3ka87eZ home]# yum install git
[root@iZuf6h59snssqyqa3ka87eZ home]# yum install golang Running transactionInstalling : golang-src-1.8.3-1.el7.noarch 1/3 Installing : golang-1.8.3-1.el7.x86_64 2/3 Installing : golang-bin-1.8.3-1.el7.x86_64 3/3 Verifying : golang-bin-1.8.3-1.el7.x86_64 1/3 Verifying : golang-src-1.8.3-1.el7.noarch 2/3 Verifying : golang-1.8.3-1.el7.x86_64 3/3 Installed:golang.x86_64 0:1.8.3-1.el7 Dependency Installed:golang-bin.x86_64 0:1.8.3-1.el7 golang-src.noarch 0:1.8.3-1.el7 Complete! 4:設(shè)置域名
[root@iZuf6h59snssqyqa3ka87eZ home]# cd ngrok [root@iZuf6h59snssqyqa3ka87eZ ngrok]# export NGROK_DOMAIN="vx.xxx.cn" 5:配置證書(shū)
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 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# openssl genrsa -out rootCA.key 2048 Generating RSA private key, 2048 bit long modulus ......................................+++ .......+++ e is 65537 (0x10001) [root@iZuf6h59snssqyqa3ka87eZ ngrok]# openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem[root@iZuf6h59snssqyqa3ka87eZ ngrok]# openssl genrsa -out device.key 2048 Generating RSA private key, 2048 bit long modulus .+++ .............+++ e is 65537 (0x10001) [root@iZuf6h59snssqyqa3ka87eZ ngrok]# openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csr [root@iZuf6h59snssqyqa3ka87eZ ngrok]# openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000 Signature ok subject=/CN=vx.xxx.cn Getting CA Private Key ? ?復(fù)制證書(shū) \cp 覆蓋不提示 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# \cp rootCA.pem assets/client/tls/ngrokroot.crt [root@iZuf6h59snssqyqa3ka87eZ ngrok]# \cp device.crt assets/server/tls/snakeoil.crt [root@iZuf6h59snssqyqa3ka87eZ ngrok]# \cp device.key assets/server/tls/snakeoil.key 6:編譯
#win服務(wù)端 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# GOOS=windows GOARCH=386 make release-server go install -tags 'release' ngrok/main/ngrokd#win客戶(hù)端 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# GOOS=windows GOARCH=386 make release-client go install -tags 'release' ngrok/main/ngrok#linux服務(wù)端 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# GOOS=linux GOARCH=386 make release-server go install -tags 'release' ngrok/main/ngrokd #linux客戶(hù)端 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# GOOS=linux GOARCH=386 make release-client go install -tags 'release' ngrok/main/ngrok 7:運(yùn)行服務(wù)端 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# ./bin/linux_386/ngrokd -domain="vx.xxx.cn" -httpAddr=":80" [18:02:40 CST 2018/01/09] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [metrics] Reporting every 30 seconds [18:02:40 CST 2018/01/09] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [registry] [tun] No affinity cache specified [18:02:40 CST 2018/01/09] [INFO] (ngrok/log.Info:112) Listening for public http connections on [::]:80 [18:02:40 CST 2018/01/09] [INFO] (ngrok/log.Info:112) Listening for public https connections on [::]:443 [18:02:40 CST 2018/01/09] [INFO] (ngrok/log.Info:112) Listening for control and proxy connections on [::]:4443 8:運(yùn)行客戶(hù)端
為客戶(hù)端編寫(xiě)一個(gè)配置文件 ngrok.cfg,然后運(yùn)行:
server_addr: "vx.xxx.cn:4443" trust_host_root_certs: false ngrok -config=./ngrok.cfg -subdomain=test 80 ? 運(yùn)行結(jié)果 Tunnel Status online Version 1.7/1.7 Forwarding http://test.vx.xxx.cn -> 127.0.0.1:80 Forwarding https://test.vx.xxx.cn -> 127.0.0.1:80 Web Interface 127.0.0.1:4040 # Conn 0 Avg Conn Time 0.00ms 9:需要把域名vx.xxx.cn
test.vx.xxx.cn 指向服務(wù)器的IP
10:指定域名
? ?客戶(hù)端啟動(dòng)參數(shù)配置即可
11:配置https
首先在阿里云申請(qǐng)免費(fèi)的ssl證書(shū),然后下載證書(shū)上傳到服務(wù)器,解壓
[root@iZuf6h59snssqyqa3ka87eZ van]# ls -l total 28 -rw-r--r-- 1 root root 1679 Jan 11 10:08 213976973460777.key -rw-r--r-- 1 root root 3292 Jan 11 10:08 213976973460777.pem -rw-r--r-- 1 root root 4258 Jan 11 10:08 213976973460777.pfx -rw-r--r-- 1 root root 1679 Jan 11 10:08 chain.pem -rw-r--r-- 1 root root 15 Jan 11 10:08 pfx-password.txt -rw-r--r-- 1 root root 1614 Jan 11 10:08 public.pem? ? 重新運(yùn)行服務(wù)端: [root@iZuf6h59snssqyqa3ka87eZ ngrok]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 10742/sshd tcp6 0 0 :::8080 :::* LISTEN 17146/docker-proxy- tcp6 0 0 :::8082 :::* LISTEN 8175/docker-proxy-c [root@iZuf6h59snssqyqa3ka87eZ ngrok]# ./bin/linux_386/ngrokd -domain="vx.xxx.cn" -httpAddr=":80" -tlsKey="./van/213976973460777.key" -tlsCrt="./van/213976973460777.pem" & [1] 2586 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# [15:58:45 CST 2018/01/12] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [registry] [tun] No affinity cache specified [15:58:45 CST 2018/01/12] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [metrics] Reporting every 30 seconds [15:58:45 CST 2018/01/12] [INFO] (ngrok/log.Info:112) Listening for public http connections on [::]:80 [15:58:45 CST 2018/01/12] [INFO] (ngrok/log.Info:112) Listening for public https connections on [::]:443 [15:58:45 CST 2018/01/12] [INFO] (ngrok/log.Info:112) Listening for control and proxy connections on [::]:4443修改客戶(hù)端配置文件 ngrok.cfg,然后運(yùn)行,就可以使用htts訪問(wèn)了
server_addr: "vx.xxx.cn:4443" trust_host_root_certs: true
總結(jié)
以上是生活随笔為你收集整理的ngrok编译和安装的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: docker svn
- 下一篇: 日志 查看匹配内容的前后几行