We had the issue with disabled websocket when hosting Rocket Chat. Our users get "Websocket is disabled for this server" error when they tryed to connect to the server from mobile clients for iOS and Android.
Thanks to Dan's post, adding this lines to config helped us:
#websocket support
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
Thus way our config became like this:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
server_name our_rocketchat_domain_url.com;
ssl_certificate "/etc/letsencrypt/live/our_rocketchat_domain_url.com/fullchain.pem";
ssl_certificate_key "/etc/letsencrypt/live/our_rocketchat_domain_url.com/privkey.pem";
ssl_ciphers our_ciphers_list;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2 TLSv1.3;
access_log /var/log/nginx/our_rocketchat_domain_url.com.access.log;
error_log /var/log/nginx/our_rocketchat_domain_url.com.error.log warn;
location / {
proxy_buffers 16 4k;
proxy_buffer_size 2k;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_pass http://ip_of_our_rocketchat:3000/;
#websocket support
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}