Trying to get ssl to n8n without reverse proxy working

Running n8n on Ubuntu 24.04 through npm.

Wanting to run ssl to n8n directly, not as an nginx reverse proxy.

Already used the following commands

export N8N_PROTOCOL=https
export N8N_SSL_KEY=/etc/…
export N8N_SSL_CERT=/etc/…

But, https doesn’t work on port 5678 still.

Am I missing something?

What kind of errors do you encounter? Anything specific that could indicate the reason? Just a timeout?

Are you using a docker image directly, or via docker compose? What does your other setup look like?

Have you tried using certbot? Or you can add nginx/caddy for security then certbot…

Yeah we use certbot + nginx reverse proxy for most setups. I’d also recommend that.

I’ve got certbot running, got the certs downloaded and everything. Specified to npm where the certs were. Still not working unfortunately.

We decided to not use docker, so went straight npm setup.

Did that end up working?

It is really recommended to not use the direct npm package, but still should, I believe, function if used right.

Unfortunately no. I had nginx as a reverse proxy. But, the n8n api won’t talk to our local install through ssl doing that for some reason.

The issue was probably more complex then. Could shed some light on more setup details and attempts? Sometimes docker has odd networking that needs to be handled.

Or the nginx reverse proxy needs to be adjusted. We’ve seen many times if the socket isn’t routed correctly you disconnect from n8n for example.

Could you provide your docker compose and nginx config? (removing any PIIs)

This is my nginx config. I’ve edited the server_name from what it actually is.
Also, we’re not running docker, we’re running the npm build.

server {
listen 80;
server_name zzz.zzzz.zzz;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name zzz.zzzz.zzz;
ssl_certificate /etc/letsencrypt/live/zzz.zzzz.zzz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/zzz.zzzz.zzzprivkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
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;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
}
}

location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:5678;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-NginX-Proxy true;
    }

Heres the setup I use. But I use it with docker, I am unsure how node deployment works with this setup. I also dont enable redirects, I think because it screws with cloudflare redirects. No 301.

Are you using certbot as well? Setup seems different from what certbot --nginx generates

I tried setting up SSL directly too, but n8n didn’t serve HTTPS until I also set N8N_PORT=443 and ran it with elevated privileges. Also make sure no firewall is blocking 443. I’m not using certbot—just passed my cert and key manually like you.

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