2022年2月

原文:Solution of nginx reverse proxy websocket response 403

The log accessed through nginx has the following entry:
DEBUG ... o.s.w.s.s.s.OriginHandshakeInterceptor   : Handshake request rejected, Origin header value https://some-host.com not allowed
Then Google queries related solutions to find the issue on GitHub, so
you only need to modify the configuration of nginx and
addproxy_set_header Origin "";That’s it.

http {

//SSL related configuration

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
    listen 8020;
    location /ws {
        proxy_pass http://some-ip:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Origin "";
    }
}

在我的access.log中并未发现关于“Origin”的信息,但是按照此方案修改配置文件后却可以解决问题。