Skip to main content
Get Caddy up and running in minutes with this quick start guide. You’ll learn how to serve static files and set up a reverse proxy with automatic HTTPS.

Prerequisites

Before you begin, make sure you have Caddy installed. See the installation guide if you haven’t installed Caddy yet. Verify your installation:
caddy version

Serve a Static Site

1

Create a simple HTML file

Create an index.html file in a new directory:
mkdir mysite
cd mysite
echo '<h1>Hello from Caddy!</h1>' > index.html
2

Start Caddy

Run Caddy with the file server:
caddy file-server
Your site is now available at http://localhost:2015

Use a Caddyfile

For more control, create a Caddyfile in your site directory:
localhost

file_server
Then start Caddy:
caddy run
Caddy automatically looks for a Caddyfile in the current directory when you run caddy run without specifying a config.

Enable Automatic HTTPS

To enable automatic HTTPS for a real domain:
example.com

file_server
For automatic HTTPS to work:
  • You must own the domain
  • DNS must point to your server
  • Ports 80 and 443 must be open
  • Caddy must be publicly accessible

Reverse Proxy

Here’s how to proxy requests to a backend application:
localhost

reverse_proxy localhost:8080
This forwards all requests to your application running on port 8080.

With Path-Based Routing

localhost

handle /api/* {
    reverse_proxy localhost:8080
}

handle {
    file_server
}

Common Caddyfile Patterns

Static Site with Compression

example.com

encode gzip
file_server

SPA (Single Page Application)

example.com

root * /var/www/myapp
try_files {path} /index.html
file_server

Reverse Proxy with Custom Headers

example.com

reverse_proxy localhost:3000 {
    header_up X-Real-IP {remote_host}
}

Multiple Sites

site1.com {
    root * /var/www/site1
    file_server
}

site2.com {
    reverse_proxy localhost:8080
}

Production Operations

1

Start Caddy as a service

Use caddy start to run in the background:
caddy start
2

Check status

caddy list-modules
3

Reload configuration

After changing your Caddyfile:
caddy reload
This performs a zero-downtime reload.
4

Stop Caddy

caddy stop

Using the Admin API

Caddy’s admin API runs on localhost:2019 by default.

Get current config

curl localhost:2019/config/

Load a new config

curl localhost:2019/load \
  -H "Content-Type: application/json" \
  -d @config.json

Next Steps

Core Concepts

Learn about Caddy’s architecture and module system

Caddyfile

Master the Caddyfile configuration format

Reverse Proxy

Deep dive into reverse proxy configuration

CLI Reference

Explore all Caddy commands

Build docs developers (and LLMs) love