Centos6.5配置ngrok实现内外穿透

2016-04-14    作者:哎丫丫    来源:哎丫丫电脑

我的服务器是centos6.5的32位操作系统,已经安装过lnmp,和其他部分程序。git也已经安装了。。
好,接下来首先安装编译此ngrok需要的环境
1:————————
yum -y install zlib-devel openssl-devel perl hg cpio expat-devel gettext-devel curl curl-devel perl-ExtUtils-MakeMaker hg wget gcc gcc-c++

2:————————
yum update

3:————————
yum install go

这样环境就算差不多了,少什么再补充吧
接下来、
4:go的命令需要做软连接到/usr/bin——————
ln -s /usr/local/go/bin/* /usr/bin/

5:接下来下载ngrok源码,编译ngrok————————
cd /usr/local/
git clone https://g i t h u b.com/inconshreveable/ngrok.git
export GOPATH=/usr/local/ngrok/
export NGROK_DOMAIN="ngrok.612459.com"
cd ngrok

6:为域名生<证书——————
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 server.key 2048
openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 5000

7:拷贝需要的证书,替换原始ngrok的证书。——k———
cp rootCA.pem assets/client/tls/ngrokroot.crt
cp server.crt assets/server/tls/snakeoil.crt
cp server.key assets/server/tls/snakeoil.key

8:编译服务端 ——————
cd /usr/local/ngrok/
GOOS=linux GOARCH=386 make release-server

//生成的服务器端名字是 /usr/local/ngrok/bin/ngrokd

9:编译客户端 ——————
  9-1:mac os 64位操作/统,下面的命令
   cd /usr/local/ngrok/
GOOS=darwin GOARCH=amd64 make release-client
  9-2:Windows的客户端编译
cd /usr/local/ngrok/
GOOS=windows GOARCH=amd64 make release-client
//生成的windows客户端名字是/usr/local/ngrok/bin/windows_amd64/ngrok.exe 下载到你的windows平台使用
 9-3:附上百度出来的参数配置

支持linux ,macos freebsd下执行

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export GOROOT=""
export GOPATH=""
export GOROOT_BOOTSTRAP=GO1.4路径
//本机环境
./all.bash
//linux
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 ./make.bash --no-clean
CGO_ENABLED=1 GOOS=linux GOARCH=386 ./make.bash --no-clean
//嵌入式linux
CGO_ENABLED=1 GOOS=linux GOARCH=arm ./make.bash --no-clean
//嵌入式freebsd
CGO_ENABLED=1 GOOS=freebse GOARCH=amd64 ./make.bash --no-clean
CGO_ENABLED=1 GOOS=freebse GOARCH=386 ./make.bash --no-clean
//mac os
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 ./make.bash --no-clean
CGO_ENABLED=1 GOOS=darwin GOARCH=386 ./make.bash --no-clean

恩,本来想搞个给路由器上运行的,但是由于那么啊。ngrok1.7版本是开源的,才能配置自己的服务端,但是他的go版本支持是1.42,那么问题就来了。不支持mips的话就是不能编译出for路由器的客户端了。这里只有for arm的客户端的编译方法

首先下载go 1.4包

wget https://storage.g o o g l e a p i s.com/golang/go1.4.2.linux-386.tar.gz
tar -zxvf go1.4.2.linux-386.tar.gz
mv go /usr/local/
然后
cd /usr/local/ngrok/
GOOS=linux GOARCH=arm make release-client
应该会出错
go build runtime: linux/arm must be bootstrapped using make.bash

我们需要
cd /usr/local/go/src
GOOS=linux GOARCH=arm ./make.bash 
直到争辩编译出支持的库文件,然后我们就可以继续去编译咯 
cd /usr/local/ngrok/

GOOS=linux GOARCH=arm make release-client

9-3:windows客户端的配置文件
 新建一个名为ngrok.cfg 的文件和ngrok.exe放在一起,6容添加
server_addr: "ngrok.612459.com:4443"
trust_host_root_certs: false



10:启动服务器端——————
/usr/local/ngrok/bin/ngrokd -domain="ngrok.612459.com" -httpAddr=":8080" -httpsAddr=":8081" -tunnelAddr=":4443"

 //此处端口有冲突的话可以自行更换端口

11:客户端链接————————
   11-1:windows客户端k接:
ngrok.exe -subdomain example -config=ngrok.cfg 8080
    11-2 :linux客户端链接:
./ngrok -config=./ngrok.cfg -subdomain=example 8080
setsid ./ngrok -config=./ngrok.cfg -subdomain=example 8080 #在linux下如果想后台运行

好。注意点说下,首先是域名必须支持泛域名三级的解析。我测试了刚好万网的是支持的。具体的见视频补充。直接丢百度盘吧视频
http://pan.b a  i d u.com/s/1bpbRZT9
然后就是比如说你换域名的话,必须要重新生成新的证书,且服务端和客户端都需要重新编译。。。

Centos6.5配置ngrok实现内外穿透

感谢前面的大神前辈给出这么好的教程,让我菜鸟也能搭建成功!!!》

./ngrok -subdomain mydatabaseserver -config=[YOUR_CONFIG_FILE_NAME] -proto tcp 3306

此命令为连接到mysql server

恩附件为的我这个服务器的windows客户端链接工具,仅限测试玩玩

附件下载
   版权声明,所有转载都有注明出处,本站不负责承担任何法律责往。若有侵权,请联系我。我会及时删除。

电脑维护,系统安装,软、硬件维修,电脑配件,零售业务,网站建设,路由器安装设置服务器维护,电脑、网络维护,智能手机刷机,安装WIFI 调试!郴州网站建设 小程序搭建 郴州电脑维修

        咨询电话:18175576644  点击这里给我发消 息
   扫描二维码。关注公众号,小程序
       享受星级服务   

手机点击二维码关注
      


手机点击打开小程序
      

阅读:2341    评论:0

相关评论

0