What is the name of the domain?
volt.im , ws.volt.im (websocket server)
What is the issue you’re encountering
Websocket doesn’t work on prod with CF, works fine locally
What steps have you taken to resolve the issue?
nginx config
server {
server_name ws.volt.im;
listen 80;
listen [::]:80;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8087;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_read_timeout 86400;
proxy_send_timeout 86400;
}
}
Copied some nginx headers from a forum discussion here. Used to help, but it no longer works.
To reproduce
https://volt.im/login
login: cftest
password: 123
then go to
https://volt.im/s/volt/test
type anything in chat and press enter. Websocket connection doesn’t work (very rarely it does), have to refresh the page to see the message.
On localhost it works 100% of the time.
fritex
October 20, 2024, 10:23pm
2
alexander7:
ws.volt.im
alexander7:
listen 80
alexander7:
proxy_pass http
alexander7:
:8087
Either should be WS and HTTP or WSS and HTTPS.
You’r link and domain is over HTTPS, therefrom you should consider using WSS.
Are WebSockets enabled at Cloudflare dashboard → Network → WebSockets?
Should be running over a compatible HTTP(S) port with Cloudflare as well:
For Nginx, even over HTTP and Flexible SSL, it was working for my case.
I’d suggest you to check below topics, all posts for troubleshooting and more help:
Off-topic a bit and some might argue about my SSL settings, however I remember I’ve had some issues with WebSockets on a proxied naked-domain hostname.
Nevertheless, it’s still running a python app using WebSockets over Nginx and using the Flexible SSL (not having a SSL at origin, but I’ve managed to get it working with ws) at Cloudflare with the domain.vhost parameters for the domain which I am sharing to you from below:
client_max_body_size 100M;
location / {
proxy_set_header H…
Maybe, you need to change in Nginx vhost file to the location / (naked domain) instead of /formlistener/ (app URLs), as if the app is working on /formlistener/ as like mine (defined to work under /chat/)?
Either not using WebSockets, or something is working.
On the Console I see Socket via WSS, but in Network tab only HTTPS requests, no WS(S) connection made.
1 Like
It uses wss:
from console:
NEW SOCKET url="wss://ws.volt.im/
from js code:
const socket_url_prod = `wss://ws.volt.im`;
Cloudflare dashboard → Network → WebSockets
is enabled
I have flexible SSL.
Do I perhaps need to set up secure ws on the server via letsencrypt and use Full SSL?
i’m pretty sure that nginx directive need some more proxy settings, like for some headers and somethings to make the server handle the request ( as @M4rt1n said that CF dun blocking the request but my server can’t handle it ), if you have any idea about add more settings for nginx to make it handle the websocket requests help me with that please, thanks.
This is the topic I copied my nginx config from initially. And it used to work fine. Then it stopped for some reason.