错误贴图

nginx代理websocket错误处理_第1张图片

nginx日志报400 bad request错误

修改nginx配置文件

添加一下三行

server {

    listen 80;

    server_name  localhost;

    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;


    location / {

        #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://127.0.0.1:8000;

        proxy_http_version 1.1;    #添加

        proxy_set_header Upgrade $http_upgrade;    #添加

        proxy_set_header Connection "upgrade";    #添加

    }


}