centos7下搭建ngrok服务器进行内网穿透

栏目: 服务器 · 发布时间: 6年前

内容简介:以下以阿里云centos7服务器为例,并且已经安装好git、golang并替换生成

以下以阿里云centos7服务器为例,并且已经安装好git、golang

一、下载ngrok

cd /data/wwwroot
git clone https://github.com/tutumcloud/ngrok.git

二、生成ngrok使用的https证书

cd /data/wwwroot/ngrok
NGROK_DOMAIN="ngrok.test.com"
openssl genrsa -out base.key 2048
openssl req -new -x509 -nodes -key base.key -days 10000 -subj "/CN=$NGROK_DOMAIN" -out base.pem
openssl genrsa -out server.key 2048
openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
openssl x509 -req -in server.csr -CA base.pem -CAkey base.key -CAcreateserial -days 10000 -out server.crt

并替换

cp base.pem assets/client/tls/ngrokroot.crt
cp server.crt assets/server/tls/snakeoil.crt
cp server.key assets/server/tls/snakeoil.key

三、编译服务端

make release-server

生成 bin/ngrok

四、编译客户端

GOOS=windows GOARCH=amd64 make release-client

生成 bin/windows_amd64/ngrok.exe
ngrok.exe 下载到你电脑

mac下编译: GOOS=darwin GOARCH=amd64 make release-client

五、运行服务端

后台运行

nohup ./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="ngrok.test.com" -httpAddr=":3080" -httpsAddr=":3043" >/dev/null 2>log &

注意事项

1、3080,3043端口可以改成80,443,如果这两个端口空闲的话。

2、阿里云安全组开放3080、3043、4443端口,4443是默认的客户端通信端口。

3、iptables开放3080、3043、4443端口。

4、域名解析*.ngrok,记得带上*.,不然无法匹配xxx.ngrok.test.com三级域名。

六、运行客户端

编译配置文件ngrok.cfg

server_addr: "ngrok.test.com:4443"
trust_host_root_certs: false

运行

ngrok -config=ngrok.cfg -subdomain abc 8080

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Ajax for Web Application Developers

Ajax for Web Application Developers

Kris Hadlock / Sams / 2006-10-30 / GBP 32.99

Book Description Reusable components and patterns for Ajax-driven applications Ajax is one of the latest and greatest ways to improve users’ online experience and create new and innovative web f......一起来看看 《Ajax for Web Application Developers》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

URL 编码/解码
URL 编码/解码

URL 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具