N8n access with https

Hello,

Not understanding why, I cannot display log traces via the “console.log” function in the Code node of a simple test workflow, I launched my n8n instance under Docker from Chrome via http and its local IP address and not from its domain via https. This time I have the traces in the n8n tab console in Chrome. I also notice that I have several errors in this console when I use my domain name via https and mapped via nginx. Step by step (node ​​by node) of a workflow does not work well with https, which is not the case with http.

Here is the context and configuration files.

n8n version: **1.42.1**
Database (default: SQLite): **SQLite**
n8n EXECUTIONS_PROCESS setting (default: own, main): **own**
Running n8n via (Docker, npm, n8n cloud, desktop app): **docker**
Operating system: **Debian 12 (64 bits)**

Docker n8n instance launch file

# Launch Workflow rapidely
# export EXECUTIONS_PROCESS=main

# Set the logging level to 'debug'
export N8N_LOG_LEVEL=debug

# Set log output to both console and a log file
export N8N_LOG_OUTPUT=console,file

# Set a save location for the log file
export N8N_LOG_FILE_LOCATION=/tmp/n8n.log

# Set a 50 MB maximum size for each log file
export N8N_LOG_FILE_MAXSIZE=50

# Set 60 as the maximum number of log files to be kept
export N8N_LOG_FILE_MAXCOUNT=60

export N8N_HOST=n8n.pcopine.com
export N8N_PROTOCOL=https

docker run -it -d --rm --name n8n -p 80:80 -p 5678:5678 \
  -e N8N_LOG_FILE_LOCATION=$N8N_LOG_FILE_LOCATION \
  -e N8N_LOG_LEVEL=$N8N_LOG_LEVEL \
  -e N8N_LOG_OUTPUT=$N8N_LOG_OUTPUT \
  -e N8N_SECURE_COOKIE=false \
  -e N8N_DEFAULT_BINARY_DATA_MODE=filesystem \
  -e N8N_HOST=$N8N_HOST \
  -e N8N_PROTOCOL=$N8N_PROTOCOL \
  -e WEBHOOK_URL=https://n8n.pcopine.com/ \
  -v ~/.n8n:/home/node/.n8n n8nio/n8n:latest

nginx process status

$ systemctl status nginx <CR>
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running) since Sun 2024-04-28 10:35:21 CEST; 1 month 2 days ago
       Docs: man:nginx(8)
   Main PID: 118492 (nginx)
      Tasks: 5 (limit: 9262)
        CPU: 1min 13.052s
     CGroup: /system.slice/nginx.service
             ├─118492 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             ├─118502 "nginx: worker process"
             ├─118503 "nginx: worker process"
             ├─118504 "nginx: worker process"
             └─118505 "nginx: worker process"

Apr 28 10:35:21 r2 systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
Apr 28 10:35:21 r2 systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server.
Apr 28 10:35:23 r2 systemd[1]: Reloading nginx.service - A high performance web server and a reverse proxy server...
Apr 28 10:35:23 r2 nginx[118501]: 2024/04/28 10:35:23 [notice] 118501#118501: signal process started
Apr 28 10:35:23 r2 systemd[1]: Reloaded nginx.service - A high performance web server and a reverse proxy server.
$

n8n configuration file: /etc/n8n/sites-available/n8n.pcopine.com

server {
    server_name n8n.pcopine.com;
    
    # HTTP configuration
    # listen 80;
    # listen [::]:80;
    
    # HTTP to HTTPS
    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    
    # HTTPS configuration
    # listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/n8n.pcopine.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/n8n.pcopine.com/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

    location / {
        proxy_pass  http://127.0.0.1:5678/;
        proxy_buffering         off;
        proxy_redirect                      off;
        proxy_set_header  Host              $http_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_read_timeout                  900;
    }
}

Additionally, via https, I have a lot of errors in the Docker logs.

$ docker logs n8n <CR>
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
WorkflowOperationError: Only running or waiting executions can be stopped and 1156 is currently success.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
WorkflowOperationError: Only running or waiting executions can be stopped and 1157 is currently success.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
The session "xy9ob7k5at" is not registered.
…

Hey @COPINE_Patrick,

To start can you try updating your nginx config to support websockets? Something like the below might do the job.

server {
    server_name n8n.pcopine.com;
    
    # HTTP configuration
    # listen 80;
    # listen [::]:80;
    
    # HTTP to HTTPS
    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    
    # HTTPS configuration
    # listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/n8n.pcopine.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/n8n.pcopine.com/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

    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;
    }
}

Thank you for your response. I just modified the “n8n.pcopine.com” file under “/etc/nginx/sites-enabled” and restarted the nginx service. If I access the url https://n8n.pcopine.com, I get the following error: 503 Bad Bateway (nginx/1.22.1)

Sorry, I made a mistake, I didn’t restart the n8n container. Now, a priori it works. I will test further.
Thanks again.

1 Like

Naturelly, now this problem is solved. Thank you

1 Like

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