Mailing List Archive

WSS request not being upgraded via Nginx
I'm attempting to upgrade a WSS request on Varnish 4 via Nginx.

[varnish]
sub vcl_recv {
if (req.http.Upgrade ~ "(?i)websocket") {
return (pipe);
}
}

sub vcl_pipe {
if (req.http.upgrade) {
set bereq.http.upgrade = req.http.upgrade;
}
}

[nginx]
server {
listen 8080 default_server;

location /socket {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}

When initiating a WSS connection the request fails with "426 Upgrade header
MUST be provided", although the header is provided by the client.

When forcing the Upgrade header in Nginx:

proxy_set_header Upgrade "websocket";

The request passes to the backend and produces a new connection, the client
however does not receive a response back and times out.

Is there anything i can do to debug this further?

Thank you and regards,
Olivier
Re: WSS request not being upgraded via Nginx [ In reply to ]
Hi,

What's the purpose of nginx here? Can't you pipe directly to the backend
and skip nginx altogether?

Cheers,

--
Guillaume Quintard


On Sat, Dec 22, 2018 at 1:41 PM Olivier Keun <olivier.keun@gmail.com> wrote:

> I'm attempting to upgrade a WSS request on Varnish 4 via Nginx.
>
> [varnish]
> sub vcl_recv {
> if (req.http.Upgrade ~ "(?i)websocket") {
> return (pipe);
> }
> }
>
> sub vcl_pipe {
> if (req.http.upgrade) {
> set bereq.http.upgrade = req.http.upgrade;
> }
> }
>
> [nginx]
> server {
> listen 8080 default_server;
>
> location /socket {
> proxy_pass http://127.0.0.1:8081;
> proxy_http_version 1.1;
> proxy_set_header Upgrade $http_upgrade;
> proxy_set_header Connection "Upgrade";
> }
>
> When initiating a WSS connection the request fails with "426 Upgrade
> header MUST be provided", although the header is provided by the client.
>
> When forcing the Upgrade header in Nginx:
>
> proxy_set_header Upgrade "websocket";
>
> The request passes to the backend and produces a new connection, the
> client however does not receive a response back and times out.
>
> Is there anything i can do to debug this further?
>
> Thank you and regards,
> Olivier
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>