Deployment Overview of ComfyUI on Server¶
Prerequisites and Basic Requirements¶
The deployment of ComfyUI requires a Linux-based server environment with the following specifications:
-
Operating System: Debian-based distribution (e.g., Ubuntu, Debian).
-
Privileges: Root access or
sudoprivileges are required to install packages, manage services, and configure the system. -
Network: The server must have outbound internet access to clone repositories, download Python packages, and retrieve AI models.
-
Ports:
-
Port
8188: Internal port used by the ComfyUI application. -
Port
443: External port used for secure HTTPS access via the Nginx proxy.
FQDN of the Final Panel¶
The application is accessible via the following Fully Qualified Domain Name (FQDN) format on the hostkey.in domain:
-
Format:
comfyui<Server ID>.hostkey.in:443 -
Zone:
hostkey.in -
Prefix:
comfyui -
External Path:
/
File and Directory Structure¶
The application and its supporting components are organized within the following directory structure:
-
Application Source:
/root/ComfyUI -
Contains the main ComfyUI codebase cloned from the official repository.
-
User Data and Workflows:
/root/ComfyUI/user/default -
Workflows:
/root/ComfyUI/user/default/workflows -
Configuration:
/root/ComfyUI/user/default/comfy.settings.json -
AI Models:
/root/ComfyUI/models/checkpoints -
Stores downloaded model files, such as
flux1-dev-fp8.safetensors. -
Nginx Proxy Configuration:
/root/nginx -
Contains the Docker Compose file (
compose.yml) for the reverse proxy and SSL management. -
Systemd Service:
/etc/systemd/system/comfyui.service -
Defines the service unit for managing the ComfyUI process.
Application Installation Process¶
The ComfyUI application is installed directly on the host system using the following steps:
-
System Updates: APT packages are updated and upgraded to ensure the latest security patches and dependencies.
-
Repository Cloning: The ComfyUI source code is cloned from
https://github.com/comfyanonymous/ComfyUI.gitinto/root/ComfyUI. -
Python Environment Setup:
-
Python 3 pip is installed via the APT package manager.
-
PyTorch, TorchVision, and TorchAudio are installed with CUDA 12.6 support using the command:
-
ComfyUI specific requirements are installed from the
requirements.txtfile located in the application directory. -
Model Deployment:
-
The Flux model (
flux1-dev-fp8.safetensors) is downloaded from Hugging Face to the checkpoints directory. -
A custom workflow file (
flux1-dev-fp8.json) is deployed to the workflows directory. -
Configuration:
-
The
comfy.settings.jsonfile is generated with default settings, including the locale set to English (en) and the new menu enabled.
Access Rights and Security¶
Security measures are implemented to restrict access and manage network traffic:
-
Hosts File Modification: The IP address
5.180.174.199is mapped tohuggingface.coin/etc/hoststo facilitate model downloads. -
Firewall: The system relies on the Nginx reverse proxy to handle external traffic on port
443, while the internal application listens on port8188. -
User Context: The application runs as the
rootuser via the Systemd service.
Docker Containers and Their Deployment¶
A Docker-based reverse proxy is deployed to handle SSL termination and routing. The deployment utilizes Docker Compose:
-
Container Image:
jonasal/nginx-certbot:latest -
Deployment Method: Docker Compose
-
Compose File Location:
/root/nginx/compose.yml -
Service Configuration:
-
Restart Policy:
unless-stopped -
Network Mode:
host -
Environment:
CERTBOT_EMAIL: Set to[email protected]
-
Volumes:
-
nginx_secrets: Mounted to/etc/letsencryptfor SSL certificate storage. -
/data/nginx/user_conf.d: Mounted to/etc/nginx/user_conf.dfor custom Nginx configurations.
-
Proxy Servers¶
The Nginx container acts as a reverse proxy to provide secure access to the ComfyUI application:
-
SSL/TLS: Managed automatically by Certbot within the Nginx container.
-
Routing:
-
External traffic on port
443is routed to the internal ComfyUI service on port8188. -
The external path is set to
/. -
Configuration: Custom Nginx configurations are stored in
/data/nginx/user_conf.dand mounted into the container.
Permission Settings¶
File and directory permissions are configured as follows:
-
ComfyUI Service File:
/etc/systemd/system/comfyui.serviceis set to0644withrootownership. -
Workflow Directory:
/root/ComfyUI/user/default/workflowsis set to0755. -
Workflow File:
/root/ComfyUI/user/default/workflows/flux1-dev-fp8.jsonis set to0644. -
Nginx Directory:
/root/nginxis set to0644withrootownership. -
Compose File:
/root/nginx/compose.ymlis set to0644withrootownership.
Location of Configuration Files and Data¶
Key configuration files and data locations are summarized below:
| File or Directory | Path | Description |
|---|---|---|
| Application Source | /root/ComfyUI | Main ComfyUI codebase |
| Settings File | /root/ComfyUI/user/default/comfy.settings.json | User preferences and UI settings |
| Workflow File | /root/ComfyUI/user/default/workflows/flux1-dev-fp8.json | Default workflow definition |
| Model Checkpoints | /root/ComfyUI/models/checkpoints | AI model storage |
| Systemd Service | /etc/systemd/system/comfyui.service | Service definition for ComfyUI |
| Nginx Compose | /root/nginx/compose.yml | Docker Compose configuration for proxy |
Available Ports for Connection¶
The following ports are configured for the application:
-
Port 8188: Internal port for the ComfyUI web interface (not directly exposed to the public internet).
-
Port 443: External HTTPS port managed by the Nginx proxy for secure user access.
Starting, Stopping, and Updating¶
The ComfyUI application is managed as a Systemd service. Use the following commands to control the service:
-
Start the Service:
-
Stop the Service:
-
Restart the Service:
-
Enable Auto-start on Boot:
-
Check Service Status:
To update the application, the source code in /root/ComfyUI must be updated manually (e.g., via git pull), dependencies reinstalled if necessary, and the service restarted.