Describe the problem/error/question
I have a docker n8n setup behind nginx on a subpath.
Here is my nginx config:
server {
if ($host = mysite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name mysite.com;
return 404;
}
server {
listen 443 ssl;
server_name mysite.com;
ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;
root /mnt/chest/projects/mysite.com/html;
index index.html;
# Security headers
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
location /n8n/ {
proxy_pass http://localhost:5678/;
proxy_set_header Upgrade $http_upgrade; # Added for WebSocket
proxy_set_header Connection âUpgradeâ; # Modified for WebSocket
proxy_set_header Host $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;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}
UPD2: I have also tried to add this to no success:
location ~ ^/n8n/(webhook|webhook-test) {
proxy_set_header Connection '';
chunked_transfer_encoding off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $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_buffering off;
proxy_cache off;
proxy_pass http://localhost:5678/$1;
}
Here is my docker run
command:
sudo docker run --restart=always -d -it --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n -e N8N_SECURE_COOKIE="false" -e N8N_PATH="/n8n/" -e GENERIC_TIMEZONE="Europe/Moscow" -e TZ="Europe/Moscow" -e WEBHOOK_URL="https://mysite.com/n8n/" -e N8N_PROTOCOL="https" docker.n8n.io/n8nio/n8n
What is the error message (if any)?
I feel like itâs more than Telegram, but I only tried it for Telegram yet and I need it. So, for now, I add credentials (my bot token), test connection (get âConnection tested successfullyâ), then go to the workflow and press âTest workflowâ. This gives me âLost connection to the serverâ. Workflow doesnât work.
Additionally, if I press F12 in my browser while on the workflow page and go to the Network tab, I see GET requests to wss://mysite.com/n8n/rest/push?pushRef= blocked with 401 Unauthorized error. Iâm unsure if this relates to the issue, but it felt relevant.
UPD: I have âConnection lostâ warning in the top right corner of any workflow, so itâs not about Telegram. Iâve also tried to connect to n8n directly, without nginx - and the warning was gone. So the problem is nginx, I need to configure something else for it to work. Any ideas?
Please share your workflow
Information on your n8n setup
- n8n version: 1.82.2
- Database (default: SQLite): didnât change anything, so must be SQLite
- n8n EXECUTIONS_PROCESS setting (default: own, main): Unsure what it is, havenât changed enything
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: Ubuntu Server