doganddev
Accueil Blog Boutique

Installer n8n sur Debian

DOG&DEV · 25/01/2025

Gaming Patch Management Docker Node.js
Installer n8n sur Debian

Installer n8n sur Debian

n8n est un outil d’automatisation de workflows (IFTTT-like, self‑hosted). Ce guide décrit l’installation sur Debian via npm ou Docker, la configuration de base, un reverse proxy (Nginx), systemd et le dépannage. Pour Docker : install-docker-linux. Pour Nginx : nginx-phpfpm-linux.

Prérequis

  • Debian 11 ou 12
  • Node.js 18+ (ou Docker) — installer-python-linux pour le contexte Python ; pour Node : apt install nodejs npm ou nvm
  • Accès root ou sudo

Méthode 1 : npm (global)

sudo npm install -g n8n
  • Lancer : n8n. Par défaut, l’interface est sur http://localhost:5678.
  • Variables d’environnement : N8N_HOST, N8N_PORT, N8N_PROTOCOL (https si derrière reverse proxy), NODE_ENV=production, N8N_ENCRYPTION_KEY (recommandé en prod).
  • systemd : créer /etc/systemd/system/n8n.service :
[Unit]
Description=n8n
After=network.target

[Service]
Type=simple
User=www-data
Environment=NODE_ENV=production
Environment=N8N_HOST=0.0.0.0
ExecStart=/usr/bin/n8n
Restart=on-failure

[Install]
WantedBy=multi-user.target
  • Adapter User et ExecStart (chemin de n8n : which n8n). Puis :
sudo systemctl daemon-reload
sudo systemctl enable n8n
sudo systemctl start n8n

Méthode 2 : Docker

docker run -d --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n n8nio/n8n
  • Persistance : le volume n8n_data conserve workflows et config.
  • Variables : -e N8N_ENCRYPTION_KEY=xxx, -e N8N_HOST=0.0.0.0, etc.
  • docker-compose : pratique pour associer Nginx et n8n. Voir install-docker-linux.

Reverse proxy (Nginx)

server {
    listen 80;
    server_name n8n.votredomaine.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name n8n.votredomaine.com;
    ssl_certificate /etc/letsencrypt/live/n8n.votredomaine.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/n8n.votredomaine.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:5678;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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;
    }
}
  • Côté n8n : N8N_PROTOCOL=https, N8N_HOST=n8n.votredomaine.com (ou équivalent) pour que les redirections et webhooks soient corrects.

Dépannage

Symptôme Cause possible Correctif
n8n ne démarre pas Node absent, port 5678 déjà utilisé node -v ; ss -tlnp | grep 5678 ; changer N8N_PORT
Webhooks / callbacks en erreur N8N_PROTOCOL / N8N_HOST incorrects Mettre https et le host public derrière le reverse proxy
Workflows perdus après redémarrage Pas de volume/persistance Volume Docker ou répertoire ~/.n8n (npm) ; vérifier droits

Bonnes pratiques

Ressources


Cet article s’inscrit dans notre série de guides hébergement et gaming. Pour un serveur sur-mesure, contact.

Commentaires (0)

Laisser un commentaire