I was deployed n8n by docker on ubuntu vm.
On my vm have Nginx for proxy all request to n8n docker and Certbot for ssl.
But all time when I try to connect to my worked n8n instance I take 404 error for all static files and its start to not authorize me, all credential what I write on .env is not accept by n8n authorize.
Also, I will be need some database for correct work n8n in docker ?
What is the error message (if any)?
404 for static files and 401 non auth after not accept my creds
Information on your n8n setup
n8n version:
Database you’re using (default: SQLite):
Running n8n with the execution process [own(default), main]:
Running n8n via [Docker, npm, n8n.cloud, desktop app]:
server {
root /var/www/n8n.myDomain.dev/html;
index index.html index.htm index.nginx-debian.html;
server_name myDomain.dev n8n.myDomain.dev www.myDomain.dev www.myDomain.dev;
location / {
try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:5678/;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
location /assets {
proxy_pass http://127.0.0.1:5678/;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myDomain.dev/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myDomain.dev/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 = myDomain.dev) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name myDomain.dev www.myDomain.dev;
return 404; # managed by Certbot
}
.env
# Folder where data should be saved
DATA_FOLDER=/root/n8n/
# The top level domain to serve from
DOMAIN_NAME=example.com
# The subdomain to serve from
SUBDOMAIN=n8n
# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://n8n.example.com
# The user name to use for authentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_USER=user
# The password to use for authentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_PASSWORD=password
# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/Berlin
# The email address to use for the SSL certificate creation
[email protected]
When you say the credentials are not working is that in the basic auth prompt or on the webpage itself as the env options are used to set the basic auth credentials which don’t play well with the user management feature so I would start by removing those from the config.
I would probably remove the /assets location from the nginx config as it serves no value, You also don’t need the root directive. In theory all you should need in your nginx config is…
server {
server_name myDomain.dev n8n.myDomain.dev www.myDomain.dev www.myDomain.dev;
location / {
proxy_pass http://127.0.0.1:5678/;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myDomain.dev/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myDomain.dev/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 = myDomain.dev) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name myDomain.dev www.myDomain.dev;
return 404; # managed by Certbot
}
I feel like there is more to this that we can’t see. Can you share your current nginx config file? I use n8n behind nginx myself and I am not currently having this issue so I assume it is likely to be something in the config we are missing.
You could also try setting N8N_EDITOR_BASE_URL to the URL as well and see if that helps.
But its seems that not enough, because half of application sometimes can’t may to find some svg on root, or then cant find some json.
Also if refresh page on some page, it will be not found, because we can’t find our html
You shouldn’t need to set individual paths the / should cover it. I think something has gone wrong in the nginx config somewhere but I don’t know enough about nginx to fix it.
I would be tempted to revert to the original config then make the change I had above and that should work, I have just don’t it on a clean VPS to make sure it works.