socket报Error during WebSocket handshake: Unexpected response code: 404 错误

主要是添加这一段即可解决问题

proxy_http_version 1.1; 
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

以下是小随笔的nginx配置


server {
    listen 443;
    server_name www.xiaosuibi.com;
    ssl on;
    ssl_certificate  cert/1_www.xiaosuibi.com_bundle.crt;
    ssl_certificate_key cert/2_www.xiaosuibi.com.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_pass_request_headers on;
        proxy_http_version 1.1; 
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://127.0.0.1:8086;
    }
}

server {
    listen 80;
    server_name www.xiaosuibi.com xiaosuibi.com;
    rewrite ^(.*)$ https://$host$1 permanent;
}

server {
    listen 443;
    server_name xiaosuibi.com;
    return 301 https://www.xiaosuibi.com$request_uri;
}

有木有懂的大佬看下nginx配置有没有不妥的地方,我对nginx也是个半懂,哈哈
后面部署会改成docker

发表评论 已发布评论 0 《点我查看评论规范》
暂无数据