Enable n8n for Safari

Your n8n server is configured to use a secure cookie, however you are either visiting this via an insecure URL, or using Safari.

When n8n is running in a Docker container, we need to configure it differently. Let’s go through the steps to configure your Dockerized n8n instance:

  1. Docker Compose File:
    First, let’s create or modify your Docker Compose file to include the necessary configuration.
version: "3"

services:
  n8n:
    image: n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=${N8N_HOST}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_SSL_CERT=/home/node/app/certificate.pem
      - N8N_SSL_KEY=/home/node/app/key.pem
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - NODE_ENV=production
      - WEBHOOK_URL=https://${N8N_HOST}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - ${DATA_FOLDER}:/home/node/.n8n
      - ${CERT_FOLDER}/fullchain.pem:/home/node/app/certificate.pem
      - ${CERT_FOLDER}/privkey.pem:/home/node/app/key.pem
    restart: always
  1. Environment Variables:
    Create a .env file in the same directory as your Docker Compose file to store environment variables:
N8N_HOST=your-domain.com
N8N_ENCRYPTION_KEY=your-secret-encryption-key
GENERIC_TIMEZONE=UTC
DATA_FOLDER=/path/to/n8n/data
CERT_FOLDER=/path/to/ssl/certificates

Replace the placeholders with your actual values:

  • your-domain.com: The domain where your n8n instance will be accessible.
  • your-secret-encryption-key: A long, random string to encrypt sensitive data.
  • /path/to/n8n/data: The path on your host machine where n8n data will be stored.
  • /path/to/ssl/certificates: The path to your SSL certificate files.
  1. SSL Certificates:
    Ensure that you have valid SSL certificates (fullchain.pem and privkey.pem) in the directory specified by CERT_FOLDER.
  2. Start the Container:
    Run the following command in the directory containing your Docker Compose file:
docker-compose up -d

This will start n8n in detached mode.

  1. Accessing n8n:
    After starting the container, you should be able to access n8n at https://your-domain.com:5678.
  2. Security Considerations:
  • The configuration above sets up n8n to use HTTPS, which addresses the secure cookie issue.
  • Make sure your N8N_ENCRYPTION_KEY is strong and kept secret.
  • Consider setting up a reverse proxy (like Nginx) to handle SSL termination and to expose n8n on the standard HTTPS port (443).
  1. Troubleshooting:
    If you encounter issues, you can check the logs with:
docker-compose logs n8n

This configuration should resolve the secure cookie issue you were experiencing. n8n will now be running over HTTPS, ensuring that secure cookies are transmitted correctly.

Would you like me to explain any part of this Docker configuration in more detail or help with any specific aspect of setting up n8n in Docker?

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.