navdeep
1
Hi,
We are setting up N8N to run as a subfolder on http://www.example.com/automation
I’ve added the following in .env
# The subfolder to serve from
SUBFOLDER=automation
N8N_PATH=/automation/
In NGINX configuration, I’ve added a reverse proxy configuration for the n8n container
location /automation {
proxy_pass http://n8n:5678;
add_header X-Content-Type-Options nosniff;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Error we get is 404 in nginx for css and scripts to load
nginx_1 | 103.72.143.116 - - [21/Sep/2021:02:28:21 +0000] “GET /automation/css/app.1952dc89.css HTTP/1.1” 404 170 “https://www.example.com/automation/” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36” “-”
nginx_1 | 51.103.28.11 - - [21/Sep/2021:02:28:21 +0000] “GET /auth/oauth2/info?access_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIyNDcwNDE4OTU1MzQ5NTI0NTIiLCJleHAiOjE2MzIxOTg1MDAsInJvbGVzIjoiMiIsInNjb3BlIjoicHJvZmlsZSIsInN1YiI6IjI0NzEwNDI2MTE3Nzk5OTM2NSJ9.WSJVli3iNiUDbpyaPwCcY-YLWarZttxKpEmodlT1FMJmNwrj9I3kOAitLoRPppIxoxbtmD54vQHNj1M8nHPxbg HTTP/1.1” 200 224 “-” “-” “-”
nginx_1 | 103.72.143.116 - - [21/Sep/2021:02:28:21 +0000] “GET /automation/js/app.8dbcb3d5.js HTTP/1.1” 404 168 “https://www.example.com/automation/” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36” “-”
nginx_1 | 51.103.28.11 - - [21/Sep/2021:02:28:21 +0000] “GET /auth/oauth2/info?access_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIyNDcwNDE4OTU1MzQ5NTI0NTIiLCJleHAiOjE2MzIxOTg1MDAsInJvbGVzIjoiMiIsInNjb3BlIjoicHJvZmlsZSIsInN1YiI6IjI0NzEwNDI2MTE3Nzk5OTM2NSJ9.WSJVli3iNiUDbpyaPwCcY-YLWarZttxKpEmodlT1FMJmNwrj9I3kOAitLoRPppIxoxbtmD54vQHNj1M8nHPxbg HTTP/1.1” 200 224 “-” “-” “-”
nginx_1 | 103.72.143.116 - - [21/Sep/2021:02:28:21 +0000] “GET /automation/fonts.css HTTP/1.1” 404 159 “https://www.example.com/automation/” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36” “-”
nginx_1 | 51.103.28.11 - - [21/Sep/2021:02:28:21 +0000] “GET /auth/oauth2/info?access_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIyNDcwNDE4OTU1MzQ5NTI0NTIiLCJleHAiOjE2MzIxOTg1MDAsInJvbGVzIjoiMiIsInNjb3BlIjoicHJvZmlsZSIsInN1YiI6IjI0NzEwNDI2MTE3Nzk5OTM2NSJ9.WSJVli3iNiUDbpyaPwCcY-YLWarZttxKpEmodlT1FMJmNwrj9I3kOAitLoRPppIxoxbtmD54vQHNj1M8nHPxbg HTTP/1.1” 200 224 “-” “-” “-”
nginx_1 | 103.72.143.116 - - [21/Sep/2021:02:28:21 +0000] “GET /automation/js/chunk-vendors.44c26054.js HTTP/1.1” 404 178 “https://www.example.com/automation/” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36” “-”
nginx_1 | 51.103.28.11 - - [21/Sep/2021:02:28:21 +0000] “GET /auth/oauth2/info?access_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIyNDcwNDE4OTU1MzQ5NTI0NTIiLCJleHAiOjE2MzIxOTg1MDAsInJvbGVzIjoiMiIsInNjb3BlIjoicHJvZmlsZSIsInN1YiI6IjI0NzEwNDI2MTE3Nzk5OTM2NSJ9.WSJVli3iNiUDbpyaPwCcY-YLWarZttxKpEmodlT1FMJmNwrj9I3kOAitLoRPppIxoxbtmD54vQHNj1M8nHPxbg HTTP/1.1” 200 224 “-” “-” “-”
nginx_1 | 103.72.143.116 - - [21/Sep/2021:02:28:21 +0000] "GET /automation/js/app.8dbcb3d5.js
Jon
2
Hi @navdeep,
What config are you using to run n8n with?
navdeep
3
Hi @Jon, please find below my docker-compose config file for n8n
n8n:
#image: n8nio/n8n
build:
context: ./n8n/src
dockerfile: docker/images/n8n-custom/Dockerfile
ports:
- "127.0.0.1:5678:5678"
environment:
- GENERIC_TIMEZONE
- N8N_OAUTH2_AUTH_ACTIVE=true
- N8N_OAUTH2_AUTHORIZATION_URI
- N8N_OAUTH2_ACCESS_TOKEN_URI
- N8N_OAUTH2_VERIFY_URI
- N8N_OAUTH2_CLIENT_ID
- N8N_OAUTH2_SECRET
- N8N_AUTH_EXCLUDE_ENDPOINTS=css:font:fonts:fonts.css:js:rest
- N8N_OAUTH2_SCOPES=profile
- N8N_HOST=${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- N8N_PATH
- WEBHOOK_URL=https://${DOMAIN_NAME}${N8N_PATH}
- WEBHOOK_TUNNEL_URL=https://${DOMAIN_NAME}/
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${DATA_FOLDER}/.n8n:/root/.n8n
Jon
4
I think you would need the ${N8N_PATH} in your Webhook URL as well but for this one I think you just need to set
VUE_APP_URL_BASE_API=https://${DOMAIN_NAME}${N8N_PATH}
Hey @navdeep,
How are you doing? Did the above solution work for you? Let us know if you’re still stuck 
Hi Harshil,
Do you have solution for the same??
Hey @Swapnil_Chitte, did you try the solution provided by @Jon?
Sorry to dig out this old thread but I am facing the same issue as OP.
Currently, I am getting 404s on the assets folder:
My docker compose:
n8n:
stdin_open: true
restart: always
tty: true
# container_name: n8n
ports:
- 5679:5678
dns:
- 192.168.10.13
- 8.8.8.8
volumes:
- n8n_data:/home/node/.n8n
image: docker.n8n.io/n8nio/n8n
environment:
- N8N_HOST=ki.camping-stover-strand.de
- N8N_PROTOCOL=https
#- N8N_EDITOR_BASE_URL=https://ki.camping-stover-strand.de/
- WEBHOOK_URL=https://ki.camping-stover-strand.de/n8n
#- N8N_REINSTALL_MISSING_PACKAGES=true
- N8N_RUNNERS_ENABLED=true
- VUE_APP_URL_BASE_API=https://ki.camping-stover-strand.de/n8n
- WEBHOOK_TUNNEL_URL=https://ki.camping-stover-strand.de
networks:
laravel_dev:
ipv4_address: 192.168.10.222
My nginx.conf looks like this:
server {
listen 443 ssl http2;
server_name ki.camping-stover-strand.de;
# SSL configuration
ssl_certificate /etc/ssl/crt.pem;
ssl_certificate_key /etc/ssl/key.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
# Handle n8n assets specifically
location /n8n/assets/ {
proxy_pass http://192.168.10.222:5678/n8n/assets/;
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 https;
proxy_set_header X-Forwarded-Path /n8n;
proxy_set_header X-Forwarded-Prefix /n8n;
}
# Handle n8n requests - preserve /n8n/ path for all resources and API
location /n8n/ {
proxy_pass http://192.168.10.222:5678/n8n/;
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 https;
proxy_set_header X-Forwarded-Path /n8n;
proxy_set_header X-Forwarded-Prefix /n8n;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Disable buffering for real-time applications
proxy_buffering off;
# Let n8n handle its own redirects
proxy_redirect off;
}
# Laravel application
root /var/www/html/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
I am struggling to get the assets folder loaded correctly, nginx is stripping the /n8n/ from the path of the resources:
At least I think that is my current problem