日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ngrok编译和安装

發(fā)布時間:2024/9/30 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ngrok编译和安装 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1:安裝git

[root@iZuf6h59snssqyqa3ka87eZ home]# yum install git

[root@iZuf6h59snssqyqa3ka87eZ home]# yum install git Loaded plugins: fastestmirror5/6 Verifying : git-1.8.3.1-12.el7_4.x86_64 6/6 Installed:git.x86_64 0:1.8.3.1-12.el7_4 Dependency Installed:libgnome-keyring.x86_64 0:3.12.0-1.el7 perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-12.el7_4 perl-TermReadKey.x86_64 0:2.30-20.el7 rsync.x86_64 0:3.0.9-18.el7 Complete! 2:clone 代碼

[root@iZuf6h59snssqyqa3ka87eZ home]# git clone https://github.com/inconshreveable/ngrok.git ngrok Cloning into 'ngrok'... remote: Counting objects: 2732, done. remote: Total 2732 (delta 0), reused 0 (delta 0), pack-reused 2732 Receiving objects: 100% (2732/2732), 665.40 KiB | 764.00 KiB/s, done. Resolving deltas: 100% (1298/1298), done. 3:安裝go環(huán)境
[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:配置證書
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ù)制證書 \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客戶端 [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客戶端 [root@iZuf6h59snssqyqa3ka87eZ ngrok]# GOOS=linux GOARCH=386 make release-client go install -tags 'release' ngrok/main/ngrok 7:運行服務(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:運行客戶端

為客戶端編寫一個配置文件 ngrok.cfg,然后運行:

server_addr: "vx.xxx.cn:4443" trust_host_root_certs: false ngrok -config=./ngrok.cfg -subdomain=test 80 ? 運行結(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:指定域名

? ?客戶端啟動參數(shù)配置即可

ngrok -config=./ngrok.cfg -hostname=test.xxx.cn 80

11:配置https

首先在阿里云申請免費的ssl證書,然后下載證書上傳到服務(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? ? 重新運行服務(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

修改客戶端配置文件 ngrok.cfg,然后運行,就可以使用htts訪問了

server_addr: "vx.xxx.cn:4443" trust_host_root_certs: true






總結(jié)

以上是生活随笔為你收集整理的ngrok编译和安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。