首先安装GO环境,https://www.haiyun.me/archives/1009.html
cd /usr/local/src/
git clone https://github.com/inconshreveable/ngrok.git
export GOPATH=/usr/local/src/ngrok/
export NGROK_DOMAIN="haiyun.me"
生成自签名SSL证书,ngrok为ssl加密连接:
cd ngrok
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
cp rootCA.pem assets/client/tls/ngrokroot.crt
cp device.crt assets/server/tls/snakeoil.crt
cp device.key assets/server/tls/snakeoil.key
GOOS=linux GOARCH=386
make clean
make release-server release-client
如果一直停留在go get gopkg.in/yaml.v1参考:https://www.haiyun.me/archives/1011.html
启动SERVER:
bin/ngrokd -domain="$NGROK_DOMAIN" -httpAddr=":8000"
交叉编译windows客户端,最好安装最新版本Golang,使用yum安装的一直编译不通过。
cd /usr/local/go/src/
GOOS=windows GOARCH=386 CGO_ENABLED=0 ./make.bash
cd -
GOOS=windows GOARCH=386 make release-server release-client
客户端配置:
server_addr: "haiyun.me:4443"
trust_host_root_certs: false
tunnels:
http:
subdomain: "example"
auth: "user:12345"
proto:
http: "80"
ssh:
remote_port: 2222
proto:
tcp: "22"
启动客户端:
bin/ngrok -config ngrok.conf start http ssh
注意所有domain要一致,不然会出现证书错误:
Failed to read message: remote error: bad certificate
有几个问题请教下
ngrok server 是不是对应一个已被自己注册的域名,这个域名必须指向一个公网IP?
生成的 ngrokd 可以自动打开端口么?还是需要设置防火墙?
server 和 client 可以在同一个位于子网的主机中么?
望大神赐教
1.对外提供服务要注册域名,自己使用也可以使用任意域名然后修改hosts
2.视你防火墙设置
3.可以。
请教一下:
执行 make release-server release-client 的时候,一直卡在:
Fetching https://gopkg.in/yaml.v1?go-get=1
Parsing meta tags from https://gopkg.in/yaml.v1?go-get=1 (status code 200)
get "gopkg.in/yaml.v1": found meta tag main.metaImport{Prefix:"gopkg.in/yaml.v1", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v1"} at https://gopkg.in/yaml.v1?go-get=1
gopkg.in/yaml.v1 (download)
是怎么回事呢?
参考这个https://www.haiyun.me/archives/1011.html
多谢,解决了。
auth: "user:12345"
请问在哪里生成用户名和密码的?
发错了,不用管
cd -
GOOS=windows GOARCH=386 make release-server release-client
这部出错了
[root@nsos go]# GOOS=windows GOARCH=386 make release-server release-client
make: *** No rule to make target `release-server'. Stop.
can't load package: src/ngrok/client/main.go:5:2: cannot find package "github.com/inconshreveable/mousetrap" in any of:
/usr/lib/golang/src/pkg/github.com/inconshreveable/mousetrap (from $GOROOT)
/usr/local/src/ngrok/src/github.com/inconshreveable/mousetrap (from $GOPATH)
can't load package: src/ngrok/client/metrics.go:4:2: cannot find package "github.com/rcrowley/go-metrics" in any of:
/usr/lib/golang/src/pkg/github.com/rcrowley/go-metrics (from $GOROOT)
Git版本:git version 1.7.12.4
这个是什么原因呢,VPS是 Digital Ocean ,所以应该不是防火墙问题吧
请问一下,如何让 ngrok server 和机器上的 web server 共存?
我机器上本来运行的有 apache2 占用 80 端口,ngrokd 就跑不起来,必须停止 apache2 服务才能开启 ngrokd 。
这两个东西能否都跑在80端口上?
同IP同端口只能一个服务监听,除非不同IP或不同端口。
您好,请问一下,我客户端和服务端都编译成功了,down到本地启动是这个样子,没有Forwarding,要怎么解决呢?
Tunnel Status online
Version 1.7/1.7
Web Interface 127.0.0.1:4040
# Conn 0
Avg Conn Time 0.00ms
大神, 为什么我在make clean 就出错了呢 ?你能帮我看看吗 。。。474495758@qq.com。感激不尽
go clean -i -r ngrok/...
can't load package: package ngrok/cache
imports container/list
imports runtime
imports runtime/internal/sys: cannot find package "runtime/internal/sys" in any of:
/usr/local/go/src/runtime/internal/sys (from $GOROOT)
/usr/local/src/ngrok/src/runtime/internal/sys (from $GOPATH)
can't load package: src/ngrok/client/main.go:5:2: cannot find package "github.com/incon
大侠,
请问哪里有 tunnels 详细参考资料,谢谢
请问下服务器端如何控制权限让通过权限认证的客户端才能连接?现在这样只要有自编译的客户端程序都可以直接连上服务器。