这里写自定义目录标题
微信小程序,通过实时聊天增强客户体验,websocket首屈一指,看了网上些许资料,终于搞定,特记录此,相关技术:springboot mongodb nginx websocket,如有符合你的技术架构,不胜荣幸。
唉,最近写博客的频率低了很多,几乎一年2-3篇,太丢人了,抓紧拾起来吧,此文有帮助到你的话,可以加我微信Hz_Net_Media,发你后台和小程序源码,备案来源csdn即可。
废话不多说,本人分以下几步
一、申请https域名证书
- 小程序连接后台必须用https,申请一个https域名证书,如htttps://zhouxilei.xian
二、配置nginx
- nginx 》》conf 下粘贴申请的证书文件
- 编辑nginx.cof,配置如下
server {
listen 80;
listen 443 ssl http2;
server_name zhouxilei.xian;
root html;
index index.html index.htm;
ssl_certificate 4228261_zhouxilei.xian.com.pem;
ssl_certificate_key 4228261_zhouxilei.xian.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/;
}
location /wss {
proxy_pass http://localhost:8080/zhouxilei/websocket/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_he