N8N Self-Hosted

Hi. I have used the docker-compose to up the container, but i have some situations.
1 - I have websites on the VPS that use ports 80 and 443
2 - When up with traeffik, show that can’t use ports 80 and 443
3 - I tried up without traeffic and the container does’t have internet connection, i cant’t ping for google for example.
4 - I tried with docker run, same issue, the container dont’t have internet connection.
5 - I have created the A record on DNS but that point to my website.
6 - I just have connection on container when i use the host network on docker-compose, but i cant’t use the URL just the IP and without SSL

My docker-compose
version: “3”

services:
n8n:
image: n8nio/n8n
restart: always
ports:
- ‘127.0.0.1:5678:5678’

environment:
  - N8N_BASIC_AUTH_ACTIVE=true
  - N8N_BASIC_AUTH_USER
  - N8N_BASIC_AUTH_PASSWORD
  - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
  - N8N_PORT=5678
  - N8N_PROTOCOL=https
  - NODE_ENV=production
  - WEBHOOK_URL=https://${DOMAIN_NAME}${N8N_PATH}
  - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}

volumes:
- ${DATA_FOLDER}/.n8n:/home/node/.n8n
- ${DATA_FOLDER}/n8n-local-files:/files

My .env

Folder where data should be saved

DATA_FOLDER=/root/n8n/

The top level domain to serve from

DOMAIN_NAME=h3code.com.br

The subdomain to serve from

SUBDOMAIN=myn8n

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=pass

Optional timezone to set which gets used by Cron-Node by default

If not set New York time will be used

GENERIC_TIMEZONE=America_SaoPaulo

The email address to use for the SSL certificate creation

[email protected]

My docker run

docker run -d --restart always --name myn8n -p 127.0.0.1:5678:443 -e N8N_HOST=“myn8n.h3code.com.br” -e N8N_PORT=443 -e N8N_PROTOCOL=“https” -e WEBHOOK_TUNNEL_URL=“https://myn8n.h3code.com.br/” -e EXECUTIONS_DATA_PRUNE=true -v /home/root/n8n-local-files:/files -v ~/.n8n:/home/node/.n8n n8nio/n8n

use this, I ran it like this and it gives you email support to send passwords to multiple users. use firewall to map the ports to 5678

version: "3"

services:
  
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "0.0.0.0:5678:5678"

    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_EDITOR_BASE_URL=YOUR URL
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=PASSWORD

      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - GENERIC_TIMEZONE=Asia/Bangkok (COUNTRY AND ZONE)
      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_PORT=587
      - N8N_SMTP_HOST=smtp.gmail.com
      - N8N_SMTP_USER= YOUR EMAIL
      - N8N_SMTP_PASS=YOU PASSWORD
      - N8N_SMTP_SENDER=N8NCHEMEX
      - N8N_SMTP_SSL=false
1 Like

Thanks for the answer.

I tried, but the container starts without internet connection and open just with ipaddress.

have you checked your docker settings? usually the container will run a bridge with your host machine

Yeah, i found the problem, a proxy on CloudFlare DNS, i removed from the A Record and works.

Thanks for your time.

2 Likes