1.下载go
- 地址 (提取码: znrq)
- 名称:
go1.14.2.linux-amd64.tar.gz
ngrok 是一个反向代理,通过在公共的端点和本地运行的 Web 服务器之间建立一个安全的通道
2.解压go1.14.2.linux-amd64.tar.gz
到/usr/local
目录下
cd /soft
tar -zxvf go1.14.2.linux-amd64.tar.gz -C /usr/local
3.解压go完成之后,修改环境变量
vi /etc/profile
GOROOT=/usr/local/go
PATH=$GOROOT/bin:$PATH
export PATH
下面是多环境配置的方式(与本文无关,可以忽略):
JAVA_HOME=/usr/local/java/jdk1.8.0_171
CLASSPATH=.:$JAVA_HOME/lib/tools.jar
GOROOT=/usr/local/go
GITROOT=/usr/local/git
PATH=$JAVA_HOME/bin:$GOROOT/bin:$GITROOT/bin:$PATH
export JAVA_HOME CLASSPATH PATH
4.编译生效
source /etc/profile
5. 验证是否安装成功
go version
[root@localhost ~]# go version
go version go1.14.2 linux/amd64
6.下载git前先安装依赖环境
yum -y install zlib-devel openssl-devel perl cpio expat-devel gettext-devel
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
7.下载git
cd /soft
wget https://www.kernel.org/pub/software/scm/git/git-2.7.3.tar.gz
8.解压git
tar zxvf git-2.7.3.tar.gz
9.安装git
新建git文件夹
mkdir /usr/local/git
进入解压好的 git-2.7.3 目录
cd /soft/git-2.7.3
- 设置安装路径
./configure --prefix=/usr/local/git
- 编译
make
- 安装
make install
10.修改环境变量
vi /etc/profile
GITROOT=/usr/local/git
PATH=$GITROOT/bin:$PATH
export PATH
11.编译生效
source /etc/profile
12. 验证是否安装成功
git version
[root@localhost cert]# git version
git version 2.7.3
13.git克隆ngrok源码
cd /usr/local
git clone https://github.com/inconshreveable/ngrok.git
14.生成自签名ssl证书
"dengwq.com" 替换为你自己的域名
cd /usr/local/ngrok
mkdir cert
生成证书
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=dengwq.com" -days 5000 -out rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -subj "/CN=dengwq.com" -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000
分别复制并覆盖rootCA.pem
、device.crt
、device.key
证书
\cp rootCA.pem ../assets/client/tls/ngrokroot.crt
\cp device.crt ../assets/server/tls/snakeoil.crt
\cp device.key ../assets/server/tls/snakeoil.key
15.编译linux版本服务器端ngrokd
cd /usr/local/ngrok
GOOS=linux GOARCH=amd64 make release-server
16.编译windows版本客户端ngrok
GOOS=windows GOARCH=amd64 make release-client
17.启动服务端
./bin/ngrokd -domain="dengwq.com" -httpAddr=":8080"