n8n-dashboard
# N8N Admin Dashboard A small admin dashboard for managing an n8n instance. It provides: - Monitor n8n container status and uptime - Update n8n Docker image version - Create and upload data backups to S3 - One-click deploy of the admin dashboard itself ## Tech stack - Server: Node.js (Express) - Frontend: React (Vite + Tailwind) - Shell scripts: backup, update version, deploy ## Requirements - Node.js >= 22 - Docker + Docker Compose - AWS CLI configured (for backups to S3) - Git (for self-deploy from repo) ## Quick start (development) ```bash # install deps npm install # run server and Vite client npm run dev ``` - Server: http://localhost:3333 - Client (Vite): http://localhost:5173 ## Environment configuration The server reads environment variables from your shell or a `.env` in the project root. The backup and update scripts read `.env` from your n8n data/stack folder. Server (project root) variables: ```bash # .env (project root) PORT=3333 # optional, default 3333 DATA_FOLDER=/path/to/n8n-stack # folder containing n8n .env and docker-compose.yml REPO_FOLDER=/absolute/path/to/this/repo # required for Deploy Updates action ``` n8n stack/data folder variables (used by backup + update): ```bash # ${DATA_FOLDER}/.env (required for backup and version update) # for backups BACKUP_PREFIX=n8n-prod S3_BUCKET=your-bucket S3_REGION=us-east-1 # optional S3_FOLDER=backups/n8n # for version updates; this will be edited in-place by the script N8N_DOCKER_VERSION=1.64.0 ``` AWS CLI must be configured on the host running backups: ```bash aws configure ``` ## Running in production ### Install the service ```bash cd /root git clone [email protected]:herculift/automation.git cd automation npm install npm run build node --inspect server.js >> server.log & (OR npm run start) ``` Alternatively, use the in-app “Deploy Updates” button (see below) which runs the `scripts/deploy.sh` script: - Pulls latest `origin/<branch>` (default `main`) - Installs deps and builds - Restarts the Node server (systemd service configured) ### Configure systemd service for node app 1. Create a file at `/etc/systemd/system/n8n-manager.service` with the following content: ``` [Unit] Description=N8N Admin Dashboard [Service] ExecStart=/root/.nvm/versions/node/v23.11.0/bin/node server.js >> server.log Restart=always User=root Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production WorkingDirectory=/root/automation [Install] WantedBy=multi-user.target ``` 2. Enable and Start the Service. ``` systemctl enable n8n-manager systemctl start n8n-manager systemctl status n8n-manager ``` 3. Troubleshooting if you have any error running the service. ``` journalctl -u n8n-manager # Error tracking systemctl daemon-reload # Reloading daemon config ``` ### EXPOSE the port for web service ``` sudo ufw allow 3333 ``` ### Configure caddy to make the webservice accessible from internet 1. Create a domain for the webservice 2. Point the domain to the same server as N8N. 3. Update `/root/n8n-docker-caddy/caddy_config/Caddyfile` by adding the following line: ``` webservice.buink.com { reverse_proxy {HOST_IP}:3333 } ``` 4. Restart docker to apply changes ``` docker compose down docker compose up -d ``` **In case there is nginx server configured as reverse proxy, you need to update the nginx configuration** ### Long-running Data Backup endpoint (timeouts) The `POST /api/runBackupData` endpoint can take a few minutes. If you are behind a reverse proxy (Caddy or Nginx), increase the proxy timeouts for this path so the connection is not closed early. Caddy (inside your site block): ```caddy # Allow the backup endpoint to run for ~3 minutes route /api/runBackupData* { reverse_proxy {HOST_IP}:3333 { transport http { read_timeout 190s write_timeout 190s } } } ``` Nginx (inside your server config): ```nginx # Increase timeouts for the backup endpoint only location /api/runBackupData { proxy_pass http://{HOST_IP}:3333; proxy_read_timeout 190s; proxy_send_timeout 190s; } ``` After updating, reload your proxy: - Caddy: `caddy reload` (or restart your Caddy container) - Nginx: `nginx -s reload` (or `systemctl reload nginx`) ### Access the webservice Open the browser and hit `webservice.buink.com`. Follow the screen guide to upgrade n8n version. ## Features ### Status - Endpoint: `GET /api/status` - Returns `{ success: true, status: "running" | "stopped", version, uptime, lastDeployTime }` - Internally parses `docker ps` and finds `docker.n8n.io` image line ### Version Manager - Lists available Docker tags from Docker Hub - Endpoint: `GET /api/getAvailableN8NVersions` - Update version: - Endpoint: `POST /api/updateN8NVersion` - Body: `{ "version": "TAG" }` - Effect: - Edits `${DATA_FOLDER}/.env` replacing `N8N_DOCKER_VERSION` - Stops container `docker-caddy-n8n-x` - Runs `docker compose up -d` Important: - Make sure `${DATA_FOLDER}` points to your n8n deployment folder that contains `.env` and `docker-compose.yml` - Confirm your reverse proxy/container name `docker-caddy-n8n-x` matches your setup ### Data Backup - Endpoint: `POST /api/runBackupData` - Runs `scripts/backup_n8n_data.sh` which: - Creates tarball from `n8n_data` Docker volume - Uploads to `s3://$S3_BUCKET/$S3_FOLDER/$BACKUP_PREFIX-YYYYmmddHHMMSS.tar.gz` - Requires `${DATA_FOLDER}/.env` to include `BACKUP_PREFIX`, `S3_BUCKET`, `S3_REGION` - Requires AWS CLI credentials present in `~/.aws/credentials` ### Deploy Updates (self-deploy) - Endpoint: `POST /api/deployUpdates` - Requires `REPO_FOLDER` to be set - Script `scripts/deploy.sh`: - `git fetch --all --prune` - `git checkout <branch>` (default `main`) - `git pull --rebase --autostash origin <branch>` - `npm ci` or `npm install` - `npm run build` - Restart `node server.js` in background ## Scripts (manual usage) ```bash # update n8n version (edits ${DATA_FOLDER}/.env and restarts compose) bash scripts/update_n8n_version.sh <VERSION> [DATA_FOLDER] # create and upload backup to S3 bash scripts/backup_n8n_data.sh [DATA_FOLDER] # deploy this dashboard from repo path and optional branch (default main) bash scripts/deploy.sh <REPO_PATH> [BRANCH] ``` ## Troubleshooting - Backups failing: - Ensure `~/.aws/credentials` exists and `S3_BUCKET`, `S3_REGION`, `BACKUP_PREFIX` set in `${DATA_FOLDER}/.env` - Check `/tmp/n8n_backup` and the upload step - Version update not taking effect: - Confirm `N8N_DOCKER_VERSION` is present in `${DATA_FOLDER}/.env` - Confirm your compose project and container names match your environment - Check `docker compose up -d` output - Deploy Updates not working: - Ensure `REPO_FOLDER` is a valid git repo path with correct permissions - Check logs: `/tmp/n8n-dashboard-deploy.log` and `/tmp/n8n-admin-server.log` ## License MIT