rendora icon indicating copy to clipboard operation
rendora copied to clipboard

Does It Support Websocket?

Open ghost opened this issue 5 years ago • 3 comments

My stack is like: External World <-> nginx <-> rendora <-> nginx <-> daphne <-> django

I am using websocket connections. When I was doing External World <-> nginx <-> daphne <-> django

It worked well. But when I implemented rendora and added another proxy to nginx, it does not work. Websocket connection fails while handshakes. My nginx conf is like below:

server {
        listen 8000;

        location / {
                include proxy_params;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_pass http://unix:/home/ubuntu/myproject/myproject.sock;
        }
}

server {
        server_name mydomain;
        charset utf-8;

        location /static {
                alias /home/ubuntu/myproject/apps/web-build/static;
        }
 location /      {
                include proxy_params;
                proxy_pass http://127.0.0.1:3001;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

    listen 443 ssl; # managed by Certbot
   ...
}

So location / 443 port sends all requests to 127.0.0.1:3001 where rendora is listening. And rendora forward them to 127.0.0.1:8000 nginx proxy to connect to daphne unix socket. Rendora works well except the websocket requests. It would be helpful if there is a nginx configuration example.

ghost avatar Sep 25 '19 04:09 ghost

I solved it by making /graphql websocket requests going directly to Daphne server. I still have no idea why websocket connection does not work when I route them to another nginx proxy server.

location /graphql {
                        include proxy_params;
                        proxy_pass http://unix:/home/ubuntu/myproject/myproject.sock;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";
                    }

location /      {
          include proxy_params;
          proxy_pass http://127.0.0.1:3001;
            }

ghost avatar Sep 26 '19 01:09 ghost

Anyway it looks like it does not work with remote website. I have tried remote URL as backend and it seems to refuse to connect.

WebSocket connection to 'ws://127.0.0.1/ws2/?lang=en&desk=1' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Might it be because in config target is used as http:? If so, how to set multiple targets or specify target by mask.

AlexanderTserkovniy avatar Nov 12 '19 14:11 AlexanderTserkovniy

I got what was the issue, when rendora proxies to the server it does not include port, thus when for examples service is communicating with itself relatively (/ws2), it seems to forget to pass the port to connection.

AlexanderTserkovniy avatar Nov 12 '19 16:11 AlexanderTserkovniy