文章

WebSocket中nginx配置

1
2
3
4
5
6
7
8
9
10
    location /infra/ws {
        proxy_pass http://yudao-server:48080/infra/ws;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade; #必须添加
        proxy_set_header Connection "upgrade"; #必须添加
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

注意不能添加return将80端口转发到443端口!!!

本文由作者按照 CC BY 4.0 进行授权