Deploy n8n on Plesk with Docker Compose, systemd & Nginx

Learn how to deploy n8n as a durable background service on a Plesk host. This guide walks through running n8n in Docker, binding it to localhost, reverse-proxying with Plesk’s Nginx, and managing the lifecycle via systemd — all while keeping your stack secure and maintainable.

Table of Contents

Run n8n as a durable background service on a Plesk host with local-only Docker networking and Plesk’s Nginx as the public reverse proxy.

Why this guide

n8n is a popular automation/workflow tool. On Plesk servers you can keep your stack tidy by:

  • Running n8n in Docker (isolated, easy upgrades)
  • Binding it to 127.0.0.1 (not publicly exposed)
  • Using Plesk’s Nginx as the SSL/TLS reverse proxy
  • Managing lifecycle via systemd so it behaves like a service (starts on boot, simple systemctl control)

This post shows all the pieces end‑to‑end.


Prerequisites

  • Ubuntu 22.04/24.04 with Docker Engine and Docker Compose v2 installed
  • Plesk Obsidian with Proxy mode enabled for your domain
  • A DNS record for the hostname (e.g., n8n.example.com) pointing to the server
  • Basic shell access as root (or sudo)

Security model: n8n listens on 127.0.0.1:5678 only; Plesk terminates HTTPS and reverse‑proxies to the container.


1) Create a project directory and .env

Pick a working directory (example path):

Create a .env file for Compose variable expansion:


2) compose.yaml for n8n

This configuration runs n8n detached, auto‑restarts, and stores state on a named volume. It binds to localhost so only Plesk can reach it.

Bring it up:

Check it:


3) Manage with systemd (start on boot)

Create /etc/systemd/system/n8n-compose.service:

Enable and start:

Troubleshooting: If you see status=200/CHDIR, the WorkingDirectory doesn’t exist. Fix the path or use -f /full/path/compose.yaml on ExecStart/ExecStop.


4) Plesk Nginx reverse proxy

In Plesk, go to Websites & Domains → Apache & Nginx Settings → Additional Nginx directives and paste the following (adjust payload size/timeouts to taste):

Save/apply, then test over HTTPS:

Plesk’s Let’s Encrypt extension will keep certificates renewed. The Nginx location above proxies the entire site to n8n; if you prefer a sub‑path (e.g., /n8n/), you’ll need to set n8n’s base path variables and rewrite rules—ask us for a tailored snippet.


5) Updates & maintenance

  • Update n8n:
  • Backups: snapshot/backup the n8n_data volume (or copy /var/lib/docker/volumes/<project>_n8n_data/_data).
  • Logs: docker compose logs -f n8n
  • Resource usage: docker stats

6) Common pitfalls

  • Port already in use: something else bound to 127.0.0.1:5678. Change the host port or stop the conflicting service.
  • Plesk returns 502/504: increase proxy_read_timeout; confirm the container is healthy and reachable via curl http://127.0.0.1:5678/.
  • Large uploads fail: raise client_max_body_size in the Nginx directives.
  • Time zone confusion: prefer IANA zones like America/Los_Angeles for DST-aware behavior. For fixed offsets with no DST, use Etc/GMT+8 (note the reversed sign convention).
  • systemd fails CHDIR: verify WorkingDirectory and path names; run docker compose config for syntax validation.

7) Optional hardening

  • Keep n8n private to localhost (as shown). If you must expose directly, enable HTTPS on the container or put a dedicated reverse proxy in front—Plesk already does this safely.
  • Add IP allow‑lists or HTTP auth at Nginx for admin paths.
  • Consider a WAF/CDN (Cloudflare/Sucuri) in front of Plesk, but be sure to pass WebSocket upgrades.

Conclusion

With Docker Compose, systemd, and Plesk’s Nginx, n8n runs like a first‑class service: isolated, auto‑starting, and secured behind Plesk’s TLS.

If you’d like help tailoring this to your environment (multi‑tenant Plesk, alternative base paths, Cloudflare/Sucuri in front, automated backups, or HA setups), Reliable Penguin can assist.

 

Have a project or a problem?

Talk with a senior engineer for practical recommendations—no obligation.

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.