ngrok服务器搭建

℡╲_俬逩灬. 提交于 2019-12-10 14:54:52

ngrok服务器搭建

  • 资源 ngrok git网址:https://github.com/inconshreveable/ngrok go语言安装:https://golang.org/dl/ ---要求能翻墙 我安装的go-1.4 git的最新版本(最好git-2.x)

  • 我的安装环境 centos6 x32位

  • go安装 go环境配置 在.bash_profile中 #go set export GOROOT=/usr/local/go export GOOS=linux export GOARCH=386 export GOBIN=$GOROOT/bin

      PATH=$PATH:$GOBIN
      export PATH
    

    --- source .bash_profile 使配置生效

    下载go1.4 到 /usr/local 解压 生成go目录 cd go/src ./all.bash 完成安装 go versin :  go version go1.4.3 linux/386  ---一定要先安装好go语言

  • 开始安装ngork 生成自签名SSL证书: www.liven.site为我的域名 $ cd ~/goproj/src/github.com/inconshreveable/ngrok $ openssl genrsa -out rootCA.key 2048 $ openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=liven.site" -days 5000 -out rootCA.pem $ openssl genrsa -out device.key 2048 $ openssl req -new -key device.key -subj "/CN=liven.site" -out device.csr $ openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000

      执行完以上命令,在ngrok目录下就会新生成6个文件:
    

    -rw-rw-r– 1 ubuntu ubuntu 1001 Mar 14 02:22 device.crt -rw-rw-r– 1 ubuntu ubuntu 903 Mar 14 02:22 device.csr -rw-rw-r– 1 ubuntu ubuntu 1679 Mar 14 02:22 device.key -rw-rw-r– 1 ubuntu ubuntu 1679 Mar 14 02:21 rootCA.key -rw-rw-r– 1 ubuntu ubuntu 1119 Mar 14 02:21 rootCA.pem -rw-rw-r– 1 ubuntu ubuntu 17 Mar 14 02:22 rootCA.srl

    生成服务器端程序: cd ngrok make release-server

    生成客户端程序: make release-client ----- ngrok将会出现在go的bin目录中 会生成linux客户端

    生成windows客户端 cd go/src GOOS=windows GOARCH=386 ./make.bash ---会在go/pkg/tool/目录下生成windows_386文件夹 cd ngork GOOS=windows GOARCH=386 make release-client ----生成可执行文件 ngrok.exe ngrok.exe将会出现在go的bin/window_386/目录中

  • 可能出现的问题 出错: GOOS="" GOARCH="" go get github.com/jteeuwen/go-bindata/go-bindata bin/go-bindata -nomemcopy -pkg=assets -tags=release \ -debug=false
    -o=src/ngrok/client/assets/assets_release.go
    assets/client/… make: bin/go-bindata: Command not found make: *** [client-assets] Error 127

    解决:在ngrok中(ngrok.git目录) mkdir bin $ cp /home/ubuntu/.bin/go14/bin/go-bindata ./bin

    参考别人安装遇到的问题: http://tonybai.com/2015/03/14/selfhost-ngrok-service/
    http://www.haiyun.me/archives/1012.html http://www.svenbit.com/2014/09/run-ngrok-on-your-own-server/ https://github.com/inconshreveable/ngrok/blob/master/docs/SELFHOSTING.md http://www.cnblogs.com/pwenlee/p/5302880.html

  • 测试连接 启动server端: cd go ./bin/ngrokd -domain="liven.site" -httpAddr=":80" -httpsAddr=":8082" -tunnelAddr=":4443"

    ---启动成功如下: [19:25:46 EDT 2016/06/29] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [registry] [tun] No affinity cache specified [19:25:46 EDT 2016/06/29] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [metrics] Reporting every 30 seconds [19:25:47 EDT 2016/06/29] [INFO] (ngrok/log.Info:112) Listening for public http connections on [::]:80 [19:25:47 EDT 2016/06/29] [INFO] (ngrok/log.Info:112) Listening for public https connections on [::]:8082 [19:25:47 EDT 2016/06/29] [INFO] (ngrok/log.Info:112) Listening for control and proxy connections on [::]:4443

    启动客户端:将ngrok.exe copy到本地windows pc 新建ngrok.cfg: server_addr: "liven.site:4443" trust_host_root_certs: false 启动: ngrok.exe -config ngrok.exe -subdomain ngrok 80 ----说明 -subdomain 后面的值会为二级域名前缀 及 ngrok.liven.site必须要配置域名映射到服务器端ip 80表示跑在本地端口的web应用

  • end

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!