|
|
5 years ago | |
|---|---|---|
| views | 5 years ago | |
| .gitignore | 5 years ago | |
| LICENSE | 5 years ago | |
| README.md | 5 years ago | |
| app.js | 5 years ago | |
| package.json | 5 years ago | |
| routes.js | 5 years ago | |
| utils.js | 5 years ago |
利用测试号来给自己的微信推送消息。
git clone https://github.com/songquanpeng/wechat-message-push.git。npm i。npm i -g pm2。使用 Nginx 反代我们的 Node.js 服务,默认端口 3000。
在 /etc/nginx/site-enabled/ 目录下创建文件 wechat-push-service.conf(主配置文件 nginx.conf 内要有 include /etc/nginx/sites-enabled/*.conf;):
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name 你的域名;
location / {
proxy_pass http://localhost:3000; # 注意如果你改变了默认端口,记得在这里进行更新
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_bypass $http_upgrade;
}
}
之后使用 certbot 申请证书:sudo certbot --nginx。
重启 Nginx 服务:sudo service nginx restart。
https://你的域名/verify,TOKEN 随意,之后点击验证。{{text.DATA}},提交后可以拿到 TEMPLATE_ID。pm2 start ./app.js --name wechat-message-push-service。https://你的域名/Hi 或 https://你的域名/push?content=Hi,如果你的微信能够收到一条内容为 Hi 的模板消息,则配置成功。