Skip to main content
Caddy is a modern HTTP server with automatic HTTPS. This guide shows how to deploy Anubis behind Caddy.

Basic Configuration

Caddy makes it simple to set up a reverse proxy with automatic TLS. Here’s a minimal Caddyfile:
Caddy automatically:
  • Obtains and renews TLS certificates via Let’s Encrypt
  • Redirects HTTP to HTTPS
  • Sets HTTP/2 and HTTP/3

Complete Example

Here’s a production-ready setup with all recommended headers: Caddyfile:
docker-compose.yml:

Automatic HTTPS

For automatic HTTPS with Let’s Encrypt:
Caddy automatically:
  1. Obtains a TLS certificate from Let’s Encrypt
  2. Renews certificates before expiration
  3. Redirects HTTP to HTTPS
No additional configuration needed!

Custom TLS Certificates

To use your own certificates:

Multiple Backends

Protect multiple applications with one Anubis instance:
Configure Anubis to accept multiple domains:

Path-Based Routing

Protect only specific paths:
Note: This requires configuring Anubis with --base-prefix /admin.

Header Configuration

Caddy automatically sets several headers, but you can customize them:

Placeholders

Caddy provides many useful placeholders:
  • {remote_host} - Client IP address
  • {scheme} - http or https
  • {host} - Host header value
  • {method} - HTTP method
  • {uri} - Request URI
  • {http.request.proto} - HTTP version
  • {http.request.tls.version} - TLS version
  • {http.request.tls.cipher_suite} - TLS cipher suite
See Caddy placeholders for the complete list.

Health Checks

Caddy can perform active health checks on Anubis:
This checks Anubis metrics endpoint every 10 seconds.

Load Balancing

Run multiple Anubis instances behind Caddy:
Important: All Anubis instances must share the same signing key:

Logging

Customize access logs:

Advanced Configuration

Custom Error Pages

Rate Limiting

Caddy can rate limit before reaching Anubis:
Note: This requires the caddy-ratelimit plugin.

Request Buffering

Testing

Test your Caddy configuration:

Troubleshooting

Certificate Issues

If Let’s Encrypt certificates fail:

IP Address Not Detected

Verify Anubis receives the correct IP:
  1. Don’t use --use-remote-address when behind Caddy
  2. Ensure header_up X-Real-IP {remote_host} is set
  3. Check Anubis logs for received IP

Connection Refused

Check that:
  1. Anubis is running: docker ps
  2. Anubis is listening on correct port
  3. Network connectivity: docker exec caddy wget -O- http://anubis:3000/

Resources