[GH-ISSUE #294] Web app: Display error messages for failing connections #226

Open
opened 2026-05-07 00:21:49 +02:00 by BreizhHardware · 2 comments

Originally created by @prabirshrestha on GitHub (Jun 1, 2022).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/294

If ntfy is hosted behind a proxy server that doesn't have websocket enabled by default, the topic subscribed keeps spinning and there is no visual indication of what is potentially wrong. I was able to notice that it was failing to connect to websocket.

Synology NAS uses nginx for its configuration and is internal implementation details. They provide an UI to enable it. https://kb.synology.com/en-us/Surveillance/tutorial/WebSocket_connection_fail_streaming_issue

You can try to reproduce it by adding it behind nginx with websockets disabled.

Originally created by @prabirshrestha on GitHub (Jun 1, 2022). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/294 If ntfy is hosted behind a proxy server that doesn't have websocket enabled by default, the topic subscribed keeps spinning and there is no visual indication of what is potentially wrong. I was able to notice that it was failing to connect to websocket. Synology NAS uses nginx for its configuration and is internal implementation details. They provide an UI to enable it. https://kb.synology.com/en-us/Surveillance/tutorial/WebSocket_connection_fail_streaming_issue You can try to reproduce it by adding it behind nginx with websockets disabled.
Author
Owner

@binwiederhier commented on GitHub (Jun 1, 2022):

Makes sense. Thanks for reporting.

<!-- gh-comment-id:1143603641 --> @binwiederhier commented on GitHub (Jun 1, 2022): Makes sense. Thanks for reporting.
Author
Owner

@c33s commented on GitHub (Aug 7, 2022):

i had the same problem. fixed it by changing the nginx config.

relevant settings:

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;

full nginx config example:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
	listen       *:443 ssl;
	server_name ntfy.example.com;

	ssl on;
	ssl_certificate           /etc/letsencrypt/live/ntfy.example.com/fullchain.pem;
	ssl_certificate_key       /etc/letsencrypt/live/ntfy.example.com/privkey.pem;
	ssl_dhparam               /etc/ssl/dhparam.pem;
	ssl_session_cache         shared:SSL:10m;
	ssl_session_timeout       5m;
	ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers               ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
	ssl_prefer_server_ciphers on;

	root /var/www/html;
	client_max_body_size 50m;
	proxy_buffering off;

	access_log            /var/log/nginx/ntfy.example.com.access.log combined;
	error_log             /var/log/nginx/ntfy.example.com.error.log;

	location ^~ /.well-known {
		index     index.html index.htm index.php;
		allow all;
	}

	location / {
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header host $host;
		proxy_connect_timeout 300;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
		proxy_pass http://unix:/var/run/ntfy/ntfy.sock:/;
	}
}

further reading:

<!-- gh-comment-id:1207501886 --> @c33s commented on GitHub (Aug 7, 2022): i had the same problem. fixed it by changing the nginx config. relevant settings: ``` proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; ``` `full nginx config example`: ``` map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen *:443 ssl; server_name ntfy.example.com; ssl on; ssl_certificate /etc/letsencrypt/live/ntfy.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/ntfy.example.com/privkey.pem; ssl_dhparam /etc/ssl/dhparam.pem; ssl_session_cache shared:SSL:10m; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS; ssl_prefer_server_ciphers on; root /var/www/html; client_max_body_size 50m; proxy_buffering off; access_log /var/log/nginx/ntfy.example.com.access.log combined; error_log /var/log/nginx/ntfy.example.com.error.log; location ^~ /.well-known { index index.html index.htm index.php; allow all; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header host $host; proxy_connect_timeout 300; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_pass http://unix:/var/run/ntfy/ntfy.sock:/; } } ``` further reading: - https://www.nginx.com/blog/websocket-nginx/ - https://www.tutorialspoint.com/how-to-configure-nginx-as-reverse-proxy-for-websocket - https://futurestud.io/tutorials/nginx-how-to-fix-unknown-connection_upgrade-variable
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#226
No description provided.