80

免费内网穿透|服务端微信异步通知的调试

 5 years ago
source link: http://www.10tiao.com/html/728/201807/2653356111/1.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本文前提:

  1. 一台搭载了2核4G的qcloud标准版云服务器,假设叫s1(分配了公网IP);

  2. s1的操作系统是Ubuntu 16.04.1 LTS 64bit;

本文目录:

  1. 安装nginx用于配置前置SSL安全证书;

  2. 安装letsencrypt的命令行工具certbot;

  3. 配置nginx以便进行域名所有权鉴定;

  4. 使用certbot鉴定域名所有权和生成3个月的免费SSL证书;

  5. 创建crontab自动更新SSL证书的定时任务和响应的脚本;

  6. 安装、配置并启动frp服务器端frps;

  7. 安装、配置并启动frp客户端frpc;

  8. 打开chrome浏览器输入域名:https://frp.shukaiming.com,检查配置结果。


动起手来:

1)安装nginx:sudo apt install nginx,截图如下:

测试安装成果:sudo nginx -t,截图如下:

2)安装certbot命令行工具:

2.1)打开官网:https://certbot.eff.org/

2.2)选择对应的软件和操作系统,这里是nginx和ubuntu,截图如下:

2.3)依次执行下面的命令安装cerbot命令行工具以及对应的依赖:

$ sudo apt update

$ sudo apt install software-properties-common

$ sudo add-apt-repository ppa:certbot/certbot

$ sudo apt update

$ sudo apt install python-certbot-nginx 


我们看着这么一段话:

当前操作系统(Ubuntu16.04)下的certbot工具的DNS插件尚未支持从Let's Encrypt的ACMEv2服务器上获取通配符证书,也就是泛域名证书(*.test.com),没关系,我们只要搞一个域名(例如 wxcallback.shukaiming.com)用来处理微信服务器的异步回调消息即可。


3)安装证书:

3.1) 给域名增加一个A  记录解析,例如下图:

3.2)sudo certbot --nginx

这是使用chrome打开https://frp.shukaiming.com,已经生效(最喜欢那把绿色的安全锁了):

3.3)打开certbot为nginx生成的vhost配置:cat /etc/nginx/sites-enabled/default,修改如下:

3.4)保存以上nginx配置并重启nginx,sudo nginx -s reload


4)安装、配置并启动服务端frps

4.1)打开:https://github.com/fatedier/frp/releases

4.2)下载frp对应系统的最新版,选择如下:

wget https://github.com/fatedier/frp/releases/download/v0.20.0/frp_0.20.0_linux_amd64.tar.gz

4.3)解压 frp_0.20.0_linux_amd64.tar.gz并安装到/usr/local/目录下,

$sudo mv frp_0.20.0_linux_amd64 /usr/local/frp0.20.0

4.4) 编辑frps.ini配置文件:sudo vi frps.ini,配置如下:

执行启动frps命令:./frps -c ./frps.ini

4.5)继续下载客户端版的frpc,地址跟上面一样:https://github.com/fatedier/frp/releases,选win64版本:

4.6)下载好了之后解压,并打开frpc.ini配置文件:

执行启动frpc命令:./frpc -c ./frpc.ini


5)由于笔者在win PC本地已经安装好了phpstudy这个工具,直接打开并启动其内置的nginx:

6)再次打开https://frp.shukaiming.com,结果如下:

完美实现。


好久没冒泡了,这篇文章主要给大家分享了一个我做小程序微信支付异步通知的处理,其中关于frp的配置项的解释,请小伙伴们移步https://github.com/fatedier/frp/blob/master/README_zh.md,直接看中文文档,frp的作者是个国人,为作者点赞,这篇文章介绍了这么好的资源,请君多打赏咯,谢谢。


关注PHP技术大全,精彩技术分享根本停不下来。

加群全栈技术讨论QQ群畅聊:374155314


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK