Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does It Support Websocket? #24

Open
ghost opened this issue Sep 25, 2019 · 3 comments
Open

Does It Support Websocket? #24

ghost opened this issue Sep 25, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 25, 2019

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
Copy link
Author

ghost commented Sep 26, 2019

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;
            }

@AlexanderTserkovniy
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant