微信公众号接口
微信公众号接口由微信服务器调用,当用户发起请求时,微信将消息封装后调用公众号的服务器接口
微信调用的接口需要由公网IP/域名提供服务
由于公众号服务器部署在Remote Liunx上,每次修改/开发接口后要上传至服务器重启服务太麻烦
现在需要一个内网穿透工具,将部署在开发机上的Web服务通过Remote Liunx映射到公网上
FastTunnel
开源社区逛了一圈决定用FastTunnel
优点: 免费、开源、跨平台、功能单一(主要就是内网穿透,没有其它乱七八糟的功能)、提供已编译的Server与Client软件
Server 配置
Linux开放端口AAAAA给Server使用,并指定站点的URL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*", "urls": "http://*:AAAAA", "EnableFileLog": false, "FastTunnel": { "WebDomain": "loolob.cn",
"WebAllowAccessIps": [ ],
"EnableForward": false,
"Tokens": [ ], } }
|
Client 配置
指定Server的ip和端口 xxx.xxx.xxx.xxx:AAAAA
指定本地提供的web服务 127.0.0.1:BBBBB
然后指定子域名,此时外网通过 http://proxy.loolob.cn:AAAAA/ 就能访问到本地的web服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "EnableFileLog": true, "ClientSettings": { "Server": { "ServerAddr": "xxx.xxx.xxx.xxx", "ServerPort": "AAAAA" },
"Token": "",
"Webs": [ { "LocalIp": "127.0.0.1", "LocalPort": "BBBBB",
"SubDomain": "proxy"
} ],
"Forwards": [ ] } }
|
Nginx 配置
用nginx转发一下proxy.loolob的请求,帮加上端口号AAAAA,免费每次请求都带个端口号
实际上还可以转发外部发来的https请求,用nginx转成http请求给FastTunnel Server (测试在Remote Linux上让FastTunnel开https服务失败了,所以FastTunnel Server实际上是监听的是80端口)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| resolver 8.8.8.8;
server { listen 80;
server_name proxy.loolob.cn;
location / { proxy_pass http://$host:33080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
}
server { listen 443 ssl http2;
server_name proxy.loolob.cn;
# 阿里云证书配置 Start ssl_certificate /root/pem/fullchain.crt; ssl_certificate_key /root/pem/private.pem; ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_prefer_server_ciphers on; # 阿里云证书配置 End
location / { proxy_pass http://$host:33080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
}
|