N8n behind Caddy without subdomain

Hello guys,

I would like to start with self-hosted n8n as I already self-host some other services.
Current setup is:

  • Caddy as a reverse proxy
  • main domain (can’t get any subdomain!!)

I tried different configs with Caddy + n8n, but in the end, I got stuck at the point where I can start n8n in Docker, and it’s running in the same network as Caddy. But when I open the page on which n8n should be running, I get a white screen with the title “n8n.io - Workflow Automation” and a couple of HTTP 404 errors.
The Caddy is configured to serve n8n on ‘https://domain/n8n/*’, but it looks like some items are loaded from ‘https://domain’ without ‘n8n’.
Like:

  • h–ps://my-domain.com/assets/polyfills-deFGRMT9.js ← this should probably be loaded from h–ps://my-domain.com/n8n/assets/…
  • h–ps://my-domain.com/rest/sentry.js instead of h–ps://my-domain.com/n8n/rest/sentry.js

Information on your n8n setup

  • n8n version: 1.99.1
  • Running n8n via: Docker
  • Operating system:

Caddy config:

my-domain.com {
    handle_path /n8n* {
        reverse_proxy n8n:5678
    }
   .....
    encode gzip
    header {
        X-Content-Type-Options "nosniff"
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
    }
}

n8n docker-compose:

services:
   n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    networks:
      - caddy_caddy-net
    environment:
      - N8N_HOST=${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${DOMAIN_NAME}
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ./local-files:/files

volumes:
  n8n_data:
  traefik_data:

networks:
  caddy_caddy-net:
    external: true

n8n .env

# DOMAIN_NAME and SUBDOMAIN together determine where n8n will be reachable from
# The top level domain to serve from
DOMAIN_NAME=my-domain.com/n8n

# The subdomain to serve from
#SUBDOMAIN=n8n

# The above example serve n8n at: https://n8n.example.com

# Optional timezone to set which gets used by Cron and other scheduling nodes
# New York is the default value if not set
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the TLS/SSL certificate creation
[email protected]