Skip to content

Caddy Https Setup

This guide shows how to add automatic HTTPS to your Faster Chat deployment using Caddy.

  • 13MB Docker image (Alpine-based)
  • Automatic HTTPS with Let’s Encrypt (zero config)
  • Auto-renewal of certificates
  • HTTP/3 support built-in
  • Perfect for one-click deployments

The included Caddyfile already works for localhost:

Terminal window
# Start with Caddy
docker compose -f docker-compose.yml -f docker-compose.caddy.yml up -d
# Access at
http://localhost
  1. Point your domain to your server (DNS A record)

  2. Edit Caddyfile - uncomment and update the production block:

chat.yourdomain.com {
reverse_proxy faster-chat:8787
# Security headers (already configured)
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
Referrer-Policy "strict-origin-when-cross-origin"
}
encode gzip zstd
}
  1. Launch with Caddy:
Terminal window
docker compose -f docker-compose.yml -f docker-compose.caddy.yml up -d
  1. That’s it! Caddy automatically:
    • Obtains SSL certificate from Let’s Encrypt
    • Renews certificates before expiry
    • Redirects HTTP → HTTPS
    • Enables HTTP/2 and HTTP/3

If you need a different port for the app:

Terminal window
# Create .env file
echo "APP_PORT=9000" > .env
echo "HOST_PORT=9000" >> .env
# Rebuild
docker compose up -d --build

Add more blocks to Caddyfile:

app1.example.com {
reverse_proxy faster-chat:8787
}
app2.example.com {
reverse_proxy faster-chat:8787
}

For testing HTTPS locally:

chat.local {
tls internal # Self-signed cert
reverse_proxy faster-chat:8787
}

Add to /etc/hosts:

127.0.0.1 chat.local

For platforms like Railway, Render, or DigitalOcean:

  1. Set environment variable:

    DOMAIN=your-app-url.railway.app
  2. Update Caddyfile to read from env:

    {$DOMAIN} {
    reverse_proxy faster-chat:8787
    }
  3. Deploy! Caddy handles the rest.

Check what’s using them:

Terminal window
sudo lsof -i :80
sudo lsof -i :443

Stop conflicting services (nginx, apache):

Terminal window
sudo systemctl stop nginx
sudo systemctl stop apache2

View Caddy logs:

Terminal window
docker compose logs caddy

Force certificate renewal:

Terminal window
docker exec -it faster-chat-caddy-1 caddy reload --config /etc/caddy/Caddyfile

Ensure ports are open:

Terminal window
# Ubuntu/Debian
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 443/udp
# RHEL/CentOS
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
ComponentSize
Faster Chat App~428 MB
Caddy Alpine~13 MB
Total~441 MB

Only 3% overhead for automatic HTTPS - totally worth it for production deployments!

  • Domain points to your server (DNS configured)
  • Ports 80 and 443 are accessible (firewall configured)
  • Caddyfile has your actual domain
  • Environment variables set (if using)
  • Container started with Caddy compose file
  • Test HTTPS access (should auto-redirect from HTTP)
  • Check SSL rating: https://www.ssllabs.com/ssltest/