rendora
rendora copied to clipboard
Does It Support Websocket?
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.
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;
}
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.
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.