Deployment Overview of ComfyUI on Server¶
Prerequisites and Basic Requirements¶
The following requirements must be met on the server before deploying the application:
-
Operating System: Linux (Ubuntu/Debian based recommended for Docker and Python3 compatibility).
-
Privileges: Root access or
sudoprivileges are required to manage Docker, firewall, and system services. -
Domain: The server must be accessible via the
hostkey.indomain. -
Ports:
-
Port
443(HTTPS) is used for external access via the Nginx proxy. -
Port
8188is the internal port used by the ComfyUI application.
Final Panel Access URL¶
The application is accessible via the Fully Qualified Domain Name (FQDN) using the format <prefix>-<Server ID>.hostkey.in. Based on the configuration provided:
-
Domain Zone:
hostkey.in -
Prefix:
comfyui -
External Port:
443(Default HTTPS, usually omitted in browser URLs) -
URL Format:
comfyui-<Server ID>.hostkey.in
Replace <Server ID> with the actual unique identifier assigned to the server instance.
File and Directory Structure¶
The deployment utilizes the following directory structure for configuration, data, and certificates:
-
/root/ComfyUI/: Contains the main ComfyUI application source code. -
/root/nginx/: Contains the Docker Compose configuration and Nginx related scripts. -
/data/nginx/: Persistent storage for Nginx user configurations and environment variables. -
/data/nginx/nginx-certbot.env: Environment file for Certbot/Nginx configuration. -
/data/nginx/user_conf.d/: Directory for custom Nginx server configurations. -
/etc/letsencrypt/: Mounted volume for SSL/TLS certificates managed by Certbot (vianginx_secretsvolume).
Application Installation Process¶
The ComfyUI application is deployed as a native system service running in the background, rather than as a Docker container. The installation involves placing the source code and creating a systemd service unit.
-
Execution Command: The application is started using Python 3 with the entry point
main.py. -
Service Manager: The application is managed by
systemdusing a unit file generated for the service. -
Version Control: The application runs the version of ComfyUI present in the
/root/ComfyUI/directory.
Docker Containers and Their Deployment¶
A reverse proxy with SSL termination is deployed using Docker. This container handles the HTTPS traffic and forwards requests to the internal ComfyUI instance.
-
Deployment Method: Docker Compose.
-
Compose File Location:
/root/nginx/compose.yml -
Container Image:
jonasal/nginx-certbot:latest -
Restart Policy:
unless-stopped
To start or restart the proxy services, the following command is used:
Docker Service Configuration¶
The Docker Compose configuration includes the following parameters:
| Parameter | Value | Description |
|---|---|---|
| Image | jonasal/nginx-certbot:latest | Nginx with built-in Certbot for SSL. |
| Network Mode | host | Uses the host's network stack directly. |
| Volume (SSL) | nginx_secrets | External volume mounted at /etc/letsencrypt for certificates. |
| Volume (Config) | /data/nginx/user_conf.d | Host directory mounted to /etc/nginx/user_conf.d for configs. |
| Environment | CERTBOT_EMAIL | Set to [email protected] for certificate notifications. |
| Env File | /data/nginx/nginx-certbot.env | Path to the environment variable file. |
Proxy Servers¶
The deployment utilizes Nginx as a reverse proxy with automatic SSL certificate management via Let's Encrypt (Certbot).
-
Proxy Image:
jonasal/nginx-certbot:latest -
SSL Provider: Let's Encrypt (Certbot)
-
Certificate Storage: Stored in the
nginx_secretsvolume at/etc/letsencrypt. -
Configuration: Custom Nginx configurations are placed in
/data/nginx/user_conf.d. -
Routing:
-
External Port:
443(HTTPS) -
External Path:
/(Root path) -
Internal Target:
localhost:8188(ComfyUI internal port) -
Internal Path: Empty (Root mapping)
Permission Settings¶
The following permission settings are applied to the relevant directories and files:
-
/root/nginx/: -
Owner:
root -
Group:
root -
Mode:
0644(Directory creation mode) -
/root/ComfyUI/main.py: -
Executable by the system user running the service (typically root or a specific service user defined in systemd).
-
/data/nginx/: -
Must be accessible by the Docker container to mount and read configuration files.
Location of Configuration Files and Data¶
| Component | File Path | Description |
|---|---|---|
| ComfyUI Source | /root/ComfyUI/ | Main application code. |
| Service Unit | /etc/systemd/system/comfyui.service | (Generated from comfyui.service.j2) |
| Docker Compose | /root/nginx/compose.yml | Configuration for the Nginx proxy. |
| Nginx Env | /data/nginx/nginx-certbot.env | Environment variables for the proxy. |
| Nginx Custom Config | /data/nginx/user_conf.d/ | Directory for custom server blocks. |
| SSL Certificates | nginx_secrets (Docker Volume) | Let's Encrypt certificates. |
Available Ports for Connection¶
-
Port 443: HTTPS. The primary entry point for users accessing the ComfyUI web interface via the FQDN.
-
Port 8188: HTTP. The internal port used by the ComfyUI application. This port is typically not exposed directly to the public internet but is accessible via the Nginx proxy.
Starting, Stopping, and Updating¶
Managing the ComfyUI Application¶
The ComfyUI application is managed as a systemd service.
-
Start the service:
-
Stop the service:
-
Restart the service:
-
Enable on boot:
Managing the Nginx Proxy¶
The Nginx proxy is managed via Docker Compose.
-
Start/Restart the proxy:
-
Stop the proxy:
Updating the Application¶
To update the ComfyUI application:
-
Update the code in the
/root/ComfyUI/directory. -
Restart the systemd service:
To update the Nginx proxy:
- Pull the latest image and recreate the container: