微信小程序配置WSS协议

配置的是nginx转发,前提是你已经安装了nginx的软件并已经正常打开网页,安装好SSL协议,能打开https网页

下面是配置:

需要的话可以根据需求修改

server {
listen 80;
server_name c21r.z1r053.com;
return 301 https://$host$request_uri;
}

upstream websocket {
server c21r.z1r053.com:2666;
}
server {
listen 443;
server_name c21r.z1r053.com;
ssl on;
root /home/wwwroot/cren/public;
index index.html index.php;

location ~* ^.+\.(jpg|jpeg|gif|png|bmp|js|css)$ {
access_log off; 
root /home/wwwroot/cren/public;
expires 30d; 
break; 


location ~ \.php$ {
root /home/www.douniu178.com /cren/public; #指定php的根目录
fastcgi_pass 127.0.0.1:9000;#php-fpm的默认端口是9000
fastcgi_index www.365soke.cn  index.php;
fastcgi_param SCRIPT_www.hbs90.cn/ FILENAME /home/wwwroot/cren/public$fastcgi_script_name;
include fastcgi_params;

ssl_certificate cert3/214550577690872.pem;
ssl_certificate_key cert3/214550577690872.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 www.hbs90.cn/ TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

location / {
root /home/wwwroot/cren/public;
index index.html index.php;
try_files $uri $uri/ www.caibaoyule.cn  /index.php?$query_string;
proxy_pass http://c21r.z1r053.com:2666;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Real-IP $remote_addr;

}
access_log /var/log/nginx/c21r.z1r053.com.log;
}

配置之后发现wss协议能打开了,但是https协议又出现问题,所以这里有几个坑需要注意下一:

1. proxy_pass http://c21r.z1r053.com:2666; 最开始这里忘记加端口号了,所以wss协议还是不通,加上端口号就好了

2.配置代理之后图片文件和css,js文件打不开,所以又配置了下面的内容解决了:

location ~* ^.+\.(jpg|jpeg|gif|png|bmp|js|css)$ {
access_log off; 
root /home/wwwroot/cren/public;
expires 30d; 
break; 

3.配置之后加入http转https:

server {
listen 80;
server_name c21r.z1r053.com;
return 301 https://$host$request_uri;
}

4.location加入重写后js文件才能正常打开:

try_files $uri $uri/ /index.php?$query_string;

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值