nginx wss websocket配置 400錯誤記錄

websocket配置項是對的,可是從http的80端口換成https的443端口,websocket沒法使用web

這是一個將443端口映射到8080端口的路徑映射,包含websocket配置,https協議配置好了,結果是ws協議的websocket能夠鏈接上,wss協議請求響應400,沒法鏈接websocket

    location /projectName{
        proxy_pass   http://127.0.0.1:8080/projectName;
        proxy_set_header X_CUSTOM_HEADER $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        #proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 「upgrade」;
        #proxy_connect_timeout 300s;
            
    }

看出問題來了嗎?proxy_set_header Connection 「upgrade」,這裏引號是中文的,可是在未使用https協議的時候,websocket也是能夠用的,換成英文引號的問題解決proxy_set_header Connection "upgrade"socket

一樣的,有時候遇到一些莫名其妙的問題,看看是否是中文空格或是中文引號引發的,可使用查找功能,看看是否有中文空格和中文引號code

相關文章
相關標籤/搜索