Using Caddy as your primary web server is super simple. But when you need to scale your application Caddy is limited to its static configuration. To o

wemake-services / caddy-gen

submited by
Style Pass
2021-06-30 02:30:04

Using Caddy as your primary web server is super simple. But when you need to scale your application Caddy is limited to its static configuration.

To overcome this issue we are using docker-gen to generate configuration everytime a container spawns or dies. Now scaling is easy!

The main idea is simple. Every labeled service exposes a virtual.host to be handled. Then, every container represents a single upstream to serve requests.

With the following settings, myapp.com will serve files from directory www and only requests to /api/* will be routed to the whoami service. See file_server.

With this custom template, Caddy-gen will act as a reverse proxy for service containers and store their logs under the appropriate host folder in /var/logs.

With this snippet, Caddy will request SSL certificates from the Let's Encrypt staging environment. This is useful for testing without running up against rate limits when you want to deploy.

Leave a Comment
Related Posts