Skip to main content
Display the current Caddy configuration (Caddyfile) from a machine in the cluster.

Usage

uc caddy config [OPTIONS]

Options

--machine, -m
string
Name or ID of the machine to get the configuration from. If not specified, uses the currently connected machine
--no-color
boolean
Disable syntax highlighting for the output

Description

The config command displays the complete Caddy configuration (Caddyfile) that’s currently running on a machine. This includes:
  • Custom global configuration (if provided via --caddyfile flag during deployment)
  • Auto-generated configuration from service port definitions
  • Service-specific Caddy configuration from compose files
The output is syntax-highlighted by default for better readability.

Examples

View Caddy config from current machine

uc caddy config
Output (with syntax highlighting):
{
    # Auto-generated Caddy configuration for Uncloud
    admin off
    auto_https disable_redirects
    log {
        level INFO
    }
}

myapp.example.com {
    reverse_proxy 10.210.0.5:8000
    
    log {
        output stdout
        format console
    }
}

api.example.com {
    reverse_proxy 10.210.1.7:3000
    
    log {
        output stdout
        format console
    }
}

*.abc123.cluster.uncloud.run {
    tls {
        dns cloudflare {env.CLOUDFLARE_API_TOKEN}
    }
}

View config from specific machine

Check configuration on a different machine:
uc caddy config --machine hetzner-server

Get plain text output

Disable syntax highlighting for scripting:
uc caddy config --no-color > caddy-config.txt

Understanding the Configuration

Auto-generated Sections

Uncloud automatically generates Caddyfile directives for:
  1. Service HTTP/HTTPS ports: From x-ports in compose files or -p flag in uc run
  2. Cluster domain wildcards: For *.CLUSTER_ID.cluster.uncloud.run domains
  3. TLS configuration: Automatic Let’s Encrypt integration
  4. Logging: Structured logging to stdout

Custom Sections

If you deployed Caddy with the --caddyfile flag, your custom configuration appears at the top of the file.

Service-specific Configuration

Services can include custom Caddy directives via the x-caddy field in compose files:
services:
  web:
    image: myapp:latest
    x-caddy: |
      encode gzip
      header X-Custom-Header "value"
These directives are inserted into the auto-generated site blocks.

Common Uses

Debug routing issues

Check if your service’s routing configuration is correct:
uc caddy config | grep -A 10 "myapp.example.com"

Verify TLS settings

Ensure HTTPS is configured properly:
uc caddy config | grep -A 5 "tls"

Export configuration

Save the current config for reference or backup:
uc caddy config --no-color > backup-$(date +%Y%m%d).caddyfile

Compare configurations

Check if configurations differ across machines:
diff <(uc caddy config -m machine-1 --no-color) \
     <(uc caddy config -m machine-2 --no-color)
All machines running Caddy should have identical configurations. If they differ, run uc caddy deploy to synchronize them.

Configuration Sources

The Caddy configuration is built from these sources (in order):
  1. Custom global config - From --caddyfile flag during deployment
  2. Service ingress rules - From HTTP/HTTPS port definitions
  3. Service-specific directives - From x-caddy in compose files
  4. Cluster domain rules - For managed *.uncld.dev domains

Troubleshooting

Configuration looks wrong

If the configuration doesn’t match your expectations:
  1. Check service definitions with uc service inspect SERVICE
  2. Verify compose file port definitions
  3. Redeploy Caddy: uc caddy deploy

Configuration differs across machines

All machines should have the same config. If they don’t:
# Force re-deployment to synchronize
uc caddy deploy

Syntax highlighting not working

If colors don’t appear:
  • Ensure your terminal supports colors
  • Try updating the Uncloud CLI
  • Use --no-color flag to disable

Build docs developers (and LLMs) love