1

I have a site that I'd like to enhance with using WebSocket based features. The site is behind an Nginx reverse proxy.

My config for the server looks like this:

    location / {
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_ignore_client_abort on;
        proxy_redirect http://weblogic:8080/ $scheme://$host:$server_port/;
        proxy_pass http://weblogic:8080/;

        access_log  /var/log/nginx/weblogic.frontend.access.log  main;
    }

The change in question is the proxy_set_header Connection "Upgrade"; line. This is the one I put in because of WebSocket.

I tried it and it works, but the problem is as soon as that line is in the config, every redirection becomes painfully slow. Requests that were done in seconds, now take half a minute to evaluate. How can I prevent this issue, while keeping the ability to use WebSocket?

PS.: I did further testing and I can confirm, that only the request that return with 302 are slow. I tried changing the proxy_redirect property to one that doesn't use variables, but I didn't have much luck.

László Stahorszki
  • 220
  • 1
  • 5
  • 14

1 Answers1

1

I found a solution. I don't know if it "solves" the problem, but it definitely covers it up nicely so far.

What I've done is put the websocket communication on a different location with the above mentioned settings, while the non-websocket location remained a normal proxy_pass-ing.

Please elaborate, if this solution is really just polishing a turd here

László Stahorszki
  • 220
  • 1
  • 5
  • 14