/rest urls return status code 404

Describe the problem/error/question

I’m running n8n with docker behind an nginx proxy. I’m able to load the frontend but all urls with /rest return status code 404

.env

DOMAIN_NAME=n8n.mydomain.duckdns.org
DATA_FOLDER=/opt/n8n

n8n.yml (docker compose)

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=${DOMAIN_NAME:-localhost}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - N8N_PATH=${N8N_PATH:-}
      - N8N_RUNNERS_ENABLED=true
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - WEBHOOK_URL=http://${DOMAIN_NAME:-localhost}/
      - GENERIC_TIMEZONE=“Europe/Brussels”
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${DATA_FOLDER:-/opt/n8n}/.n8n:/home/node/.n8n
    logging:
      options:
        max-size: "10m"
        max-file: "5"

n8n.conf (nginx)

# Redirect all HTTP traffic to HTTPS
server {
    listen 80;
    server_name n8n.mydomain.duckdns.org;

    # Permanent redirect to HTTPS
    return 301 https://$host$request_uri;

    server_tokens off;  # Hide Nginx version information
}

server {
    listen 443 ssl http2;
    server_name n8n.mydomain.duckdns.org;

    server_tokens off;  # Hide Nginx version information

    # SSL/TLS settings (using Let's Encrypt certificates)
    ssl_certificate     /etc/letsencrypt/live/mydomain.duckdns.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.duckdns.org/privkey.pem;

    # Use only secure TLS protocols
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;

    # Strong SSL ciphers for better security
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';

    # DH parameters for better security during key exchange
    ssl_dhparam /etc/ssl/private/dhparam.pem;


    location / {
    proxy_pass http://127.0.0.1:5678;
    proxy_set_header Connection 'Upgrade';
    proxy_set_header Upgrade $http_upgrade;
    proxy_http_version 1.1;
  }

    location /webhook/ {
        proxy_pass http://localhost:5678;
        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;
    }

    location /webhook-test/ {
        proxy_pass http://localhost:5678;
        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;
    }
}
ubuntu@ubuntu:~/docker-compose$ sudo docker compose up n8n
[+] Running 1/1
 ✔ Container n8n  Recreated                                                                                                                                                                                 0.1s
Attaching to n8n
n8n  | User settings loaded from: /home/node/.n8n/config
n8n  | Initializing n8n process
n8n  | n8n ready on 0.0.0.0, port 5678
n8n  | n8n Task Broker ready on 127.0.0.1, port 5679
n8n  | Version: 1.85.4
n8n  |
n8n  | Editor is now accessible via:
n8n  | https://n8n.mydomain.duckdns.org
n8n  | Registered runner "JS Task Runner" (dAYtSeDKt_J8N5m3OYdV1)

What is the error message (if any)?

Please share your workflow

/

Share the output returned by the last node

/

Information on your n8n setup

  • n8n version: 1.85.4
  • Database (default: SQLite): sqlite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): /
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: ubuntu 22.04

hello @Renaut

I see some issues with the docker config:

- N8N_PROTOCOL=https   # should be http
- N8N_PATH=${N8N_PATH:-}  # that one maybe breaks your instance. Usually you don't need to set it

- /var/run/docker.sock:/var/run/docker.sock # usually you don't need to mount that one
2 Likes

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