我使用ngrok 1客户端和服务器,使隧道到本地主机。
我运行the script来在服务器端编译ngrokd和ngrok:
NGROK_DOMAIN="my-domain.com"
git clone https://github.com/inconshreveable/ngrok.git
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
# make clean
make release-server release-client
我运行服务器:
bin/ngrokd -tlsKey=device.key -tlsCrt=device.crt -domain="$NGROK_DOMAIN" -httpAddr=":8000" -httpsAddr=":8001"
然后我只下载编译ngrok到客户端。 创建客户端配置:
NGROK_DOMAIN="my-domain.com"
echo -e "server_addr: $NGROK_DOMAIN:4443\ntrust_host_root_certs: false" > ngrok-config
并运行客户端:
./ngrok -config=ngrok-config 80
和它表明,它是在线的:
Tunnel Status online
Version 1.7/1.7
Forwarding http://4f2e0a1e.:8000 -> 127.0.0.1:80
Forwarding https://4f2e0a1e.:8000 -> 127.0.0.1:80
Web Interface 127.0.0.1:4040
# Conn 0
Avg Conn Time 0.00ms
然后,我要求http://4f2e0a1e.my-domain.com:8000
期待它传递请求到我的localhost:80
:
curl http://4f2e0a1e.my-domain.com:8000
但是答案是:
Tunnel 4f2e0a1e.my-domain.com:8000 not found
在我看到日志卷曲请求后右服务器:
[08:59:15 MSK 2019/02/02] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [pub:1ca51d1c] New connection from myClientIp:63169
[08:59:15 MSK 2019/02/02] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [pub:1ca51d1c] Found hostname 4f2e0a1e.my-domain.com:8000 in request
[08:59:15 MSK 2019/02/02] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [pub:1ca51d1c] No tunnel found for hostname 4f2e0a1e.my-domain.com:8000
[08:59:15 MSK 2019/02/02] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [pub:1ca51d1c] Closing
答案 0 :(得分:0)
实际上,$ NGROK_DOMAIN在行中为空
bin/ngrokd -tlsKey=device.key -tlsCrt=device.crt -domain="$NGROK_DOMAIN" -httpAddr=":8000" -httpsAddr=":8001"
设置NGROK_DOMAIN = my-domain.com后,它开始正常工作。
答案 1 :(得分:0)
您可以使用VMWare工作站代替oracle虚拟机 我敢肯定它会工作。 我也遇到了ngrok隧道错误。
答案 2 :(得分:0)