Sample Header Ad - 728x90

WebSocket Error "Unexpected close, re-opening websocket" after moving Focalboard to a subdirectory in Nginx

1 vote
1 answer
47 views
I'm trying to configure Focalboard to run in a specific subdirectory using Nginx. I followed the steps from the official Focalboard documentation and was able to set it up normally. However, after moving Focalboard to the /focalboard subdirectory, the WebSocket connection started showing issues. Nginx Configuration:
upstream focalboard {
   server localhost:8000;
   keepalive 32;
}

server {
   listen 443 ssl;
   server_name example.com;

   ssl_certificate /path/to/certificate.crt;
   ssl_certificate_key /path/to/certificate.key;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   ssl_ciphers HIGH:!aNULL:!MD5;

   # WebSocket configuration
   location /focalboard/ws/ {
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       client_max_body_size 50M;
       proxy_set_header Host $http_host;
       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 X-Frame-Options SAMEORIGIN;
       proxy_buffers 256 16k;
       proxy_buffer_size 16k;
       client_body_timeout 60;
       send_timeout 300;
       lingering_timeout 5;
       proxy_connect_timeout 1d;
       proxy_send_timeout 1d;
       proxy_read_timeout 1d;
       proxy_pass http://focalboard ;
   }

   # Default configuration for Focalboard
   location /focalboard/ {
       client_max_body_size 50M;
       proxy_set_header Connection "";
       proxy_set_header Host $http_host;
       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 X-Frame-Options SAMEORIGIN;
       proxy_buffers 256 16k;
       proxy_buffer_size 16k;
       proxy_read_timeout 600s;
       proxy_cache_revalidate on;
       proxy_cache_min_uses 2;
       proxy_cache_use_stale timeout;
       proxy_cache_lock on;
       proxy_http_version 1.1;
       proxy_pass http://focalboard/ ;
   }
}
Focalboard config.json:
{
    "serverRoot": "https://example.com/focalboard ",
    "port": 8000,
    "dbtype": "sqlite3",
    "dbconfig": "./focalboard.db",
    "postgres_dbconfig": "dbname=exampledb sslmode=disable",
    "useSSL": false,
    "webpath": "./pack",
    "filespath": "./files",
    "telemetry": true,
    "prometheusaddress": ":9092",
    "session_expire_time": 2592000,
    "session_refresh_time": 18000,
    "localOnly": false,
    "enableLocalMode": true,
    "localModeSocketLocation": "/var/tmp/example_local.socket"
}
After applying this configuration, I'm repeatedly getting the following error:
close, re-opening websocket
The WebSocket connection keeps closing unexpectedly and immediately reopening, which creates a constant loop. - Is there something wrong or missing in my Nginx WebSocket configuration? - How can I fix the WebSocket disconnection issue when running Focalboard in a subdirectory?
Asked by siqueir4 (11 rep)
Nov 9, 2024, 02:19 AM
Last activity: Nov 12, 2024, 07:55 AM