https://docs.n8n.io/hosting/installation/server-setups/docker-compose/#5-create-docker-compose-file
cd /root mkdir n8n vim docker-compose.yml
version: "3.7"
services:
n8n:
image: docker.n8n.io/n8nio/n8n
restart: always
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
volumes:
- ./n8n_data:/home/node/.n8n
volumes:
n8n_data:
external: true
# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from # above example would result in: https://n8n.example.com # The top level domain to serve from DOMAIN_NAME=cuidadodigital.com.br # The subdomain to serve from SUBDOMAIN=n8n # Optional timezone to set which gets used by Cron-Node by default # If not set New York time will be used GENERIC_TIMEZONE=America/Sao_Paulo # The email address to use for the SSL certificate creation #SSL_EMAIL=user@example.com
docker-compose up -d docker-compose stop chmod -R 777 n8n_data
cd /etc/nginx/sites-enabled vim n8n.conf
server {
server_name n8n.minhaempresa.com.br;
set $upstream 127.0.0.1:5678;
underscores_in_headers on;
location /.well-known {
alias /var/www/ssl-proof/minhaempresa/.well-known;
}
location / {
proxy_pass_header Authorization;
proxy_pass http://$upstream;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection “”;
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;
}
}
nginx -t systemctl reload nginx
mkdir -p /var/www/ssl-proof/minhaempresa.com.br/.well-known certbot --webroot -w /var/www/ssl-proof/minhaempresa/ -d n8n.minhaempresa.com.br -i nginx