1. 程式人生 > >ngrok編譯和安裝

ngrok編譯和安裝

1:安裝git

[[email protected] home]# yum install git

[[email protected] home]# yum install git
Loaded plugins: fastestmirror
                                                                                                                                                        5/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 程式碼
[[email protected] 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環境
[[email protected] home]# yum install golang
Running transaction
  Installing : 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:設定域名
[[email protected] home]# cd ngrok
[[email protected] 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
[[email protected] ngrok]# openssl genrsa -out rootCA.key 2048
Generating RSA private key, 2048 bit long modulus
......................................+++
.......+++
e is 65537 (0x10001)
[[email protected] ngrok]# openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem

[[email protected] ngrok]# openssl genrsa -out device.key 2048
Generating RSA private key, 2048 bit long modulus
.+++
.............+++
e is 65537 (0x10001)
[[email protected] ngrok]# openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csr
[[email protected] 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
   複製證書 \cp 覆蓋不提示
[[email protected] ngrok]# \cp rootCA.pem assets/client/tls/ngrokroot.crt
[[email protected] ngrok]# \cp device.crt assets/server/tls/snakeoil.crt 
[[email protected] ngrok]# \cp device.key assets/server/tls/snakeoil.key
6:編譯
 #win服務端
[[email protected] ngrok]# GOOS=windows GOARCH=386 make release-server 
go install -tags 'release' ngrok/main/ngrokd
 #win客戶端
[[email protected] ngrok]# GOOS=windows GOARCH=386 make release-client
go install -tags 'release' ngrok/main/ngrok
 #linux服務端
[[email protected] ngrok]# GOOS=linux GOARCH=386 make release-server
go install -tags 'release' ngrok/main/ngrokd
#linux客戶端
[[email protected] ngrok]# GOOS=linux GOARCH=386 make release-client
go install -tags 'release' ngrok/main/ngrok
7:執行服務端
[[email protected] 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
  執行結果
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 指向伺服器的IP
10:指定域名

   客戶端啟動引數配置即可

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

11:配置https

首先在阿里雲申請免費的ssl證書,然後下載證書上傳到伺服器,解壓

[[email protected] 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
    重新執行服務端:
[[email protected] 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 
[[email protected] ngrok]# ./bin/linux_386/ngrokd -domain="vx.xxx.cn" -httpAddr=":80"  -tlsKey="./van/213976973460777.key" -tlsCrt="./van/213976973460777.pem" &
[1] 2586
[[email protected] 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



相關推薦

ngrok編譯安裝

1:安裝git [[email protected] home]# yum install git [[email protected] home]# yum install git Loaded plugins: fastestmirror

dlib的編譯安裝

cmake install dcm style mic 安裝目錄 div size ckey 之前寫過python dlib依賴的安裝,安裝過程還算比較復雜,還需要安裝boost.Python依賴等,但是如果純粹的編譯C++的dlib庫,則要簡單得多,基本上不需要其

Python3.7原始碼在windows(VS2015)下的編譯安裝

Python3.7原始碼在windows(VS2015)下的編譯和安裝 下載官方原始碼,使用vs2015(WIN10SDK),最python3.7.0的原始碼進行編譯,編譯出不同的版本(release,debug),並配置python的執行環境(環境變數的配置)。 測試環境介紹和準備

Libpng的編譯安裝

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

centos7.2 Git編譯安裝

1、下載git     wget https://www.kernel.org/pub/software/scm/git/git-2.9.2.tar.gz 2、解壓     tar -xvf git-2.9.2.tar.gz 3、安裝編譯依

在centos7裡編譯安裝libnfc

一、下載libnfc程式碼 git clone https://github.com/nfc-tools/libnfc.git autoconfig -vis ./configure 出錯:找不到libusb 二、下載libusb的程式碼 wget https

Linux下的原始碼包編譯安裝原理

一、Linux原始碼包安裝過程 用於linux原始碼安裝軟體,一般下載原始碼包得到檔案:file.tar.gz和file.tar.bz2格式 (1)解壓縮 解壓命令為:  tar jxvf file.tar.bz2   tar zxvf file.tar.gz (2)配

ROS2原始碼編譯安裝

機器人開源作業系統軟體ROS在10年後, 終於推出全新架構的ROS2,代號“ardent”。中文意思為“熱心的美洲鱉”,看來ROS2要從ROS1的“海龜”變成“土鱉”系列了。與此同時,ROS2的編譯系統也換成全新的ament。之前熟悉ROS的知道,ROS最初使用rosbuil

scons使用者指南第一章:編譯安裝SCons

如果Python沒有安裝,你會看到一條錯誤訊息比如“command not found”(在UNIX或Linux裡)或"python is not recognized as an internal or external command, operable program or batch file"(在W

八、Linux原始碼包編譯安裝

8.1. 原始碼的用處 原始碼的用處無非是以下兩點 1、軟體根據使用者的需要加以定製; 2、二次開發;注:要根據軟體的許可證書約定為準,開發者許可二次開發才行; LINUX本是開源的,看大家的倔勁有多大了,呵呵,好了,下面正文開始吧,我發完就睡覺了! 8.2. 原始碼包的

windows下編譯安裝boost庫

   編譯位boost庫       我用的編譯器是vs2008,剛開始我下載的是boost_1_65_1.zip,可能boost版本太高編譯錯誤,後來我就選用boost_1_57_0.zip   

boost 原始碼編譯安裝 -fPIC

1.資源 系統:centos 7 boost原始碼:使用的是1.54版本的 boost_1_54_0.tar.gz,具體自己去boost官網下載 2.解壓boost tar -zxvf boost_1_54_0.tar.gz 注意:由於boost 預設編譯的靜態庫是沒

Linux編譯安裝boost庫

1. 下載boost安裝包並解壓縮 到http://www.boost.org/下載boost的安裝包,以boost_1_58_0.tar.gz為例 下載完成後進行解壓縮: tar zxvf boost_1_58_0.tar.gz 2.設定編譯器

VTK編譯安裝

一、       VTK開發環境 Windows7作業系統、Visual Studio 2008整合開發環境或者Visual Studio 2010整合開發環境。CMake 3.0.0,Qt 4.8.6以及VTK 5.10 Release版本。 VS開發環境08、10都可

opentsdb 編譯安裝

opentsdb在上一家公司就搞過一段時間,最近又有些時序資料需要分析處理,正好公司也在做這方面的東西,模仿opentsdb,開發了一個hitsdb,臥槽。 好吧,先來記錄一下,這個東西怎麼安裝。 首先,看下這個東西的api跟公司的hbase是否相容,公司都是0.94版本演

關於fedora上linux核心編譯安裝

裝了幾次,方法比較簡單: 1.在核心目錄下,管理員許可權執行:make menuconfig 此時在desk-live 系統下可能沒有gcc ,無法make,裝gcc即可:yum install gcc 。順便裝了g++也可以:yum install gcc g++ 不管是

編譯Boost庫】Linux下如何編譯安裝Boost庫

前言 編譯比特幣錢包時,需要依賴Boost庫,由於編譯時間較長,在“試一試”中浪費好長時間,所以把可以成功的過程記錄下來吧。 下載Boost安裝包 通過wget工具下載 wget https://dl.bintray.com/boostorg/r

在Ubuntu上下載、編譯安裝Android最新原始碼

        看完了前面說的幾本書之後,對Linux Kernel和Android有一定的認識了,是不是心裡蠢蠢欲動,想小試牛刀自己編譯一把Android原始碼了呢?一直習慣使用Windows系統,而Android原始碼是不支援在Windows上編譯上,於是決定使用虛擬機器

CentOS7編譯安裝GCC7.5

CentOS7編譯和安裝GCC7.5 一、    環境介紹: CentOS7 虛擬機器連上了網際網路(為什麼要強調這點呢,因為CentOS7每次進入系統,都需要手動點選右上角的Connect,才能連上網際網路。在非聯網情況下,會出現各種問題,影響我們的判斷和安裝) 二、 

Ubuntu12.04 下 GTK3.xx 的安裝編譯測試

start 程序 set rest gdb cal pkg 2.0 stop 用此方法成功在UBUNTU 12.04下安裝GTK 3.xxx。 一、安裝   1、安裝gcc/g++/gdb/make 等基本編程工具 $sudo apt-ge