日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

微信小程序配置WSS协议

發布時間:2025/3/20 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微信小程序配置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/wwwroot/cren/public; #指定php的根目錄
fastcgi_pass 127.0.0.1:9000;#php-fpm的默認端口是9000
fastcgi_index index.php;
fastcgi_param SCRIPT_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 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

location / {
root /home/wwwroot/cren/public;
index index.html index.php;
try_files $uri $uri/ /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;

?

轉載于:https://www.cnblogs.com/liuboswu/p/8806429.html

總結

以上是生活随笔為你收集整理的微信小程序配置WSS协议的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。