Skip to content

uxname/caddy-caddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caddy Server + Docker Compose

Production-ready setup for Caddy v2 using Docker Compose. Features automatic HTTPS (Let's Encrypt), persistent storage, and a streamlined configuration workflow.

🚀 Quick Start

  1. Clone the repository:

    git clone https://github.com/uxname/caddy-caddy.git caddy
    cd caddy
  2. Prepare the configuration: Edit ./data/Caddyfile to define your domains and proxies. (See Caddyfile.example if available for reference).

  3. Make the utility executable:

    chmod +x caddy.sh
  4. Start the server:

    docker compose up -d

🛠 Configuration Workflow

We provide a specialized tool caddy.sh to manage configuration changes safely. It replaces manual formatting, validating, and reloading.

The "One-Command" Update

After editing your Caddyfile, simply run:

./caddy.sh

What this does (in order):

  1. Format: Auto-formats your Caddyfile (fixes indentation, braces).
  2. Validate: Checks configuration for syntax errors.
  3. Reload: Applies changes to the running server only if validation passes.

Note: If validation fails, the script stops immediately. Your running server will not be reloaded, preventing downtime caused by bad config.

Granular Commands

If you need specific actions, you can run them individually:

Command Action
./caddy.sh fmt Only formats the Caddyfile (overwrite).
./caddy.sh validate Only checks the configuration syntax.
./caddy.sh reload Reloads Caddy (use with caution, prefers apply).

🐳 Docker Management

Since the script focuses on configuration, use standard Docker Compose commands for lifecycle management:

  • Start: docker compose up -d
  • Stop: docker compose down
  • Logs: docker compose logs -f caddy
  • Shell Access: docker compose exec caddy sh

📂 Project Structure

.
├── caddy.sh             # Configuration management tool
├── docker-compose.yml   # Container definition
└── data/
    ├── Caddyfile        # Your main configuration
    ├── caddy_data/      # TLS certificates (auto-managed)
    └── caddy_config/    # Internal Caddy state

📝 Best Practices

  1. Always use ./caddy.sh instead of manually reloading via Docker. This ensures your config is always clean and valid.
  2. Git Ignore: Ensure data/caddy_data and data/caddy_config are added to your .gitignore to avoid committing SSL certificates.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages