You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While Kamal 2's built-in kamal-proxy is great for zero-downtime deployments, it has some limitations compared to full-featured web servers like Traefik, Nginx, or Caddy. The main issues include:
Limited SSL/TLS configuration options
Basic routing capabilities
Restricted customization for headers, timeouts, and other advanced features
Limited integration with external certificate authorities
The Solution: Caddy + kamal-proxy Architecture
We can get the best of both worlds by:
Using Caddy as the frontend proxy handling HTTPS and advanced routing
Keeping kamal-proxy internally for zero-downtime deployments
Connecting them through Docker's internal networking
Here's how to set it up:
1. Configure kamal-proxy
First, modify kamal-proxy's boot configuration to not publish ports to the host:
#!/bin/sh# .kamal/hooks/pre-deploy
kamal proxy boot_config set \
--publish false
Better Security: Proper layered architecture with frontend proxy
Flexibility: Easy to add more complex routing, caching, or security rules
Usage
Deploy as normal with kamal deploy. Caddy will handle external traffic on ports 80/443, and forward requests to kamal-proxy, which manages your application containers.
Notes
Remember to configure DNS to point to your server's IP address
Caddy automatically handles HTTPS certificates
The internal kamal-proxy is still required for zero-downtime deployments
You can customize the Caddyfile for advanced use cases (rate limiting, caching, etc.)
This setup gives you the power of a proper web server while maintaining Kamal's deployment benefits.
The Challenge with kamal-proxy
While Kamal 2's built-in kamal-proxy is great for zero-downtime deployments, it has some limitations compared to full-featured web servers like Traefik, Nginx, or Caddy. The main issues include:
The Solution: Caddy + kamal-proxy Architecture
We can get the best of both worlds by:
Here's how to set it up:
1. Configure kamal-proxy
First, modify kamal-proxy's boot configuration to not publish ports to the host:
2. Add Caddy as an Accessory
Add this to your
config/deploy.yml
:3. Create Caddyfile
Create
config/Caddyfile
:Benefits of This Setup
Usage
Deploy as normal with
kamal deploy
. Caddy will handle external traffic on ports 80/443, and forward requests to kamal-proxy, which manages your application containers.Notes
This setup gives you the power of a proper web server while maintaining Kamal's deployment benefits.
TODO
Caddyfile
The text was updated successfully, but these errors were encountered: