Skip to content

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 sudo privileges 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:

  1. System Updates: APT packages are updated and upgraded to ensure the latest security patches and dependencies.

  2. Repository Cloning: The ComfyUI source code is cloned from https://github.com/comfyanonymous/ComfyUI.git into /root/ComfyUI.

  3. Python Environment Setup:

  4. Python 3 pip is installed via the APT package manager.

  5. PyTorch, TorchVision, and TorchAudio are installed with CUDA 12.6 support using the command:

    /usr/bin/pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
    

  6. ComfyUI specific requirements are installed from the requirements.txt file located in the application directory.

  7. Model Deployment:

  8. The Flux model (flux1-dev-fp8.safetensors) is downloaded from Hugging Face to the checkpoints directory.

  9. A custom workflow file (flux1-dev-fp8.json) is deployed to the workflows directory.

  10. Configuration:

  11. The comfy.settings.json file 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.199 is mapped to huggingface.co in /etc/hosts to 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 port 8188.

  • User Context: The application runs as the root user 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:

  • Volumes:

    • nginx_secrets: Mounted to /etc/letsencrypt for SSL certificate storage.

    • /data/nginx/user_conf.d: Mounted to /etc/nginx/user_conf.d for 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 443 is routed to the internal ComfyUI service on port 8188.

  • The external path is set to /.

  • Configuration: Custom Nginx configurations are stored in /data/nginx/user_conf.d and mounted into the container.

Permission Settings

File and directory permissions are configured as follows:

  • ComfyUI Service File: /etc/systemd/system/comfyui.service is set to 0644 with root ownership.

  • Workflow Directory: /root/ComfyUI/user/default/workflows is set to 0755.

  • Workflow File: /root/ComfyUI/user/default/workflows/flux1-dev-fp8.json is set to 0644.

  • Nginx Directory: /root/nginx is set to 0644 with root ownership.

  • Compose File: /root/nginx/compose.yml is set to 0644 with root ownership.

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:

    systemctl start comfyui
    

  • Stop the Service:

    systemctl stop comfyui
    

  • Restart the Service:

    systemctl restart comfyui
    

  • Enable Auto-start on Boot:

    systemctl enable comfyui
    

  • Check Service Status:

    systemctl status comfyui
    

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.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×