API Backend for Docker Nextcloud Provisioning and Management (WHMCS/WISECP) - n8n Workflow

Use this comprehensive n8n workflow template to automate Docker Nextcloud provisioning, suspension, termination, and monitoring via a powerful API backend, ideal for integration with WHMCS or WISECP.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Hosting providers or system integrators using WHMCS or WISECP.
DevOps specialists requiring an automation layer (n8n) to manage Docker deployment and resource allocation.
Users needing a centralized control panel to provision Nextcloud instances on specific host servers.
Developers looking for advanced n8n templates involving heavy SSH scripting and infrastructure orchestration.

Overview

This specialized n8n workflow provides a secure and high-level abstraction layer over raw infrastructure operations. Instead of manually running complex Docker Compose commands and shell scripts on multiple servers, external applications (like billing systems) trigger specific actions via a single API endpoint (the n8n trigger).

This robust n8n workflow manages the entire lifecycle of a Nextcloud deployment—including dynamic creation of dedicated disk images (data.img), mounting them via fstab, configuring Docker Compose for Nextcloud, MariaDB, Redis, and Collabora (Office), setting up Nginx VHOST files, and performing application-level commands (like managing users or checking versions) using the Nextcloud occ command line utility. This makes infrastructure management highly scalable and reliable, leveraging the flexibility of n8n nodes for complex technical orchestration.

How it Works

The entire process is initiated by an external system sending a request to the n8n webhook trigger.


  1. API Trigger & Validation (Webhook & If): The API n8n trigger receives a POST request containing the command (e.g., 'create', 'suspend', 'stats') and client parameters (domain, resource limits, server name). The flow first verifies that the target server_domain is permitted using an If n8n node.

  2. Resource Definition (Deploy-docker-compose, nginx): For provisioning or package changes, subsequent Set nodes dynamically generate the necessary docker-compose.yml (defining Nextcloud, MariaDB, Redis, and Collabora containers with resource limits) and customized Nginx configuration templates.

  3. Command Routing (Service Actions, Container Stats, NextCloud): The main logic utilizes multiple Switch n8n node instances to route the request based on the specific command.

  4. Action Execution (Set Nodes): The relevant action (e.g., Deploy, Suspend, Stat, Change Password) is routed to a corresponding Set n8n node. These nodes store complex, parameterized Bash scripts that handle file creation, disk management (using fallocate, mkfs.ext4, and losetup), Docker operations (docker-compose up/down, docker exec), Nginx configuration deployment, and asynchronous Nextcloud Office (Collabora) configuration.

  5. Server Dispatch (Servers Switch & SSH n8n node): The Servers Switch n8n node directs the dynamically generated Bash script to the correct physical Docker host via the appropriate SSH n8n node credential (d01-test.uuq.pl or d02-test.uuq.pl).

  6. DNS Updates (Optional): Commands involving creation or termination also execute a side path that interacts with the PowerDNS API (via HTTP Request n8n node) to update or delete necessary CNAME records pointing the client domain to the host server.

  7. Final Response: The output from the SSH command is parsed by a Code n8n node, converting the shell script result into a consistent JSON response structure before returning it to the external billing system via the API answer2 Respond to Webhook n8n node.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the entire JSON code and paste it directly into your n8n instance using the 'New' menu and 'Import from JSON'.

  2. Webhook Setup: The API n8n trigger uses Basic Authentication (nextcloud credential name). You must create this credential with a secure username and password that your external system will use to call the n8n workflow.

  3. SSH Credentials: Update the d01-test.uuq.pl and d02-test.uuq.pl SSH n8n node credentials. These must be set up to access your Linux Docker host servers, preferably using SSH key authentication or password access, ensuring the user has appropriate sudo permissions to manage Docker and system files (/etc/fstab).

  4. DNS Credentials (If used): Update the DNS Parametrs n8n node with your PowerDNS API URL and API Key.

  5. Workflow Parameters: Navigate to the Parametrs n8n node and update the configuration:

clientsdir: The base directory on the Docker hosts where client files and Docker Compose configurations are stored (e.g., /opt/docker/clients).
mount
dir: The root mount point for disk images (e.g., /mnt).

  1. Activate: Ensure the n8n workflow is active and copy the production webhook URL for integration with WHMCS/WISECP.

Node Details

This n8n workflow heavily relies on core functionality and custom scripting:

API (Webhook Trigger): The entry point n8n trigger. It listens for POST requests on the configured path (/docker-nextcloud) using Basic Auth to start the provisioning and management process.
If / Switch Nodes (If, If1, If2, Servers Switch, Service Actions, Container Stats, NextCloud): A complex network of flow control n8n node logic used to analyze the input command and route the execution path to the correct management script (e.g., deploy vs. suspend, stats vs. change password).
Parametrs (Set n8n node): Holds global variables (like file paths and directory structures) that are dynamically injected into the shell scripts, centralizing configuration for the entire n8n workflow.
Deploy-docker-compose / nginx (Set n8n node): These Set nodes generate the complete configuration files (docker-compose.yml and Nginx vhost snippets) dynamically using expressions based on input parameters (RAM, CPU, domain, passwords).
Deploy / Suspend / Terminated (Set n8n node): These nodes contain large, multi-step Bash scripts. For example, the Deploy script handles directory creation, disk image creation (fallocate), formatting (mkfs.ext4), mounting (via fstab), copying Nginx configurations, starting containers (docker compose up -d), and running background setup tasks for Collabora Office.
Stat / Inspect / Log (Set n8n node): Contain Bash scripts designed to execute Docker CLI commands (docker inspect, docker stats, docker logs) remotely and parse the output for structured JSON responses.
d01-test.uuq.pl / d02-test.uuq.pl (SSH n8n node): These are the critical execution nodes. They take the generated Bash script from the preceding Set node and execute it on the designated remote host server, providing the bridge between the n8n automation and the Docker infrastructure.
Add record / Delete record (HTTP Request n8n node): Used to interact with the PowerDNS API for automated domain record updates (CNAME records) after provisioning or termination.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

PUQ sp. z o.o. is an international IT company building solutions to automate cloud and IT service sales. We created PUQcloud — a free, open-source platform for billing, automation, and IT business management. We also develop modules for WHMCS and WISECP, helping people start their own business without big tech. Our offices are in Poland and Canada, with a global team.

Featured*