Reverse PROXY NGINX Problem

Describe the problem/error/question

Hi i setup n8n running inside docker, and reverse proxy nginx using let’s encrypt.
But when i access n8n direct by ip and port 5678 workflow excute working. But if i access via domain it not working (image)
This is my docker-compose file and setting nginx. I follow all docs nginx in community but i does’nt help.

version: '3'
services:
  n8n:
    image: n8nio/n8n
    container_name: n8n
    restart: always
    ports:
      - 5678:443
    environment:
      - N8N_HOST=auto2.test.online
      - N8N_PORT=443
      - N8N_PROTOCOL=https
      - WEBHOOK_TUNNEL_URL=https://auto2.test.online/
      - WEBHOOK_URL=https://auto2.test.online/
      - VUE_APP_URL_BASE_API=https://auto2.test.online/
    volumes:
      - ./n8n_data:/home/node/.n8n

Nginx config:

server {
    server_name auto2.test.online; # managed by Certbot
        location / {
                proxy_pass http://localhost:5678;
                proxy_set_header Connection '';
                proxy_http_version 1.1;
                chunked_transfer_encoding off;
                proxy_buffering off;
                proxy_cache off;
        }

location ~ ^/(webhook|webhook-test) {
         proxy_set_header Connection '';
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;
        proxy_pass http://localhost:5678;
}

 client_max_body_size 0;

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/auto2.test.online/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/auto2.test.online/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
    if ($host = auto2.test.online) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen 80 ;
        listen [::]:80 ;
    server_name auto2.test.online;
    return 404; # managed by Certbot
}

Hi @dangdh, welcome to the community!

I am sorry you are having trouble.

Starting with version 1, n8n uses websockets to send status updates from the server to the UI. For these to work your nginx config needs a few more tweaks. Check out "Connection Lost" warning - #7 by Valerian_Lebert for an example, from the looks of it I think these two lines need to be added to your server block:

    proxy_set_header Connection 'upgrade';
    proxy_set_header Upgrade $http_upgrade;
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.