部署自己的ngrok1.7服务

非常感谢https://hteen.cn/docker/docker-ngrok.html

我的服务器是ubuntu,首先登录服务器,依次运行以下命令:

docker pull hteen/ngrok
mkdir /root/ngrok
docker run --rm -it -e DOMAIN='tunnel.yourdomain.cn' -v /root/ngrok:/myfiles hteen/ngrok /bin/sh /build.sh
docker run -idt --name ngrok-server -v /root/ngrok:/myfiles -p 8082:80 -p 4432:443 -p 4443:4443  -e DOMAIN='tunnel.yourdomain.cn' hteen/ngrok /bin/sh /server.sh

运行结果显示一个token
这样,在服务器的/root/ngrok目录下则有
bin/ngrokd 服务端
bin/ngrok linux客户端
bin/darwin_amd64/ngrok osx客户端
bin/windows_amd64/ngrok.exe windows客户端
还要增加一个nginx的站点配置,转发请求

server {
listen 80;
server_name tunnel.yourdomain.cn *.tunnel.yourdomain.cn;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://serverlocalip:8082;
}
}
server {
listen 443;
server_name tunnel.yourdomain.cn *.tunnel.yourdomain.cn;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://serverlocalip:4432;
}
}
在本地电脑执行命令,下载对应的客户端,我的是mac,所以:
scp -i meixi.pem root@yourip:/root/ngrok/bin/darwin_amd64/ngrok ~/ngrok
然后在本地创建ngrok.yml文件,并填入以下内容:

server_addr: "tunnel.yourdomain.cn:4443"
trust_host_root_certs:false
tunnels:
weixin:
proto:
http:8080
subdomain:"wx"
api:
proto:
http:80
subdomain:"api"
然后在本地执行
~/ngrok –config=ngrok.yml start weixin api
就启动了。

About

Leave Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.