3 ms·
I love caddy, I used to litter my docker-compose.yaml files with Traefik labels like: labels: - traefik.enable=true - traefik.http.routers.foun
by teekert 3y ago
I love caddy, I used to litter my docker-compose.yaml files with Traefik labels like:
labels:
- traefik.enable=true
- traefik.http.routers.foundryvtt-http.entrypoints=web
- traefik.http.routers.foundryvtt-http.rule=Host(`vtt.xxx.nl`)
- traefik.http.routers.foundryvtt-http.middlewares=foundryvtt-https
- traefik.http.middlewares.foundryvtt-https.redirectscheme.scheme=https
- traefik.http.routers.foundryvtt.middlewares=foundryvtt-auth
- traefik.http.middlewares.foundryvtt-auth.basicauth.users=${foundryvtt-BASIC_AUTH}
- traefik.http.routers.foundryvtt.entrypoints=websecure
- traefik.http.routers.foundryvtt.rule=Host(`vtt.xxx.nl`)
- traefik.http.routers.foundryvtt.tls=true
- traefik.http.routers.foundryvtt.tls.certresolver=mytlschallenge
- traefik.http.services.foundryvtt.loadbalancer.server.port=30000
Now I just add the containers (by name), no labels, and map Caddy to their port, like so (in the Caddyfile):
data.xxx.com {
reverse_proxy projectsend:80
}
or, this snippet refers to a WordPress container with BasicAuth in front of it:
restricted.xxxx.com {
root * /var/www/html/restricted.xxxx.com/wordpress
php_fastcgi wordpress-xxxx-restricted:9000 {
root /var/www/html
}
basicauth /* {
xxx $xx$x05xxxxxxxxx.xx
}
file_server
}
Here's just an index.html (from Hugo in this case) in some dir:
blog.xxx.nl {
# Set this path to your site's directory.
root * /var/www/html/blog.xxx.nl
# Enable the static file server.
file_server
}
I love the simplicity.
- ilyt 3y agoThat says more about shitty trend of using labels as a config than anything else. 12 factor app did untold damage to the industry convincing smart-but-inexperienced developers that key-value-only systems are somehow good way to configure anything more complex than "this app needs server, password and user"
- teekert 3y agoWell, apart from the labels, I'm also happy I got rid of that middleware stuff that I still don't fully understand. I mean, I want https, and I want it in front of my standard docker container that listens on some random port. Caddy requires me to enter only exactly what I need, no more (container name and port and required function (rev-proxy), 2 lines, boom).
- jbverschoor 3y agoRemind me of essentially moving Java code to XML with Spring. Typical platform-in-a-platform syndrome.
- theshrike79 3y agoWait? Caddy can do all that? I really need to grab a few beers and check out the documentation, my current docker setup is a cargo-cult traefik label monster I just copied from a friend =) It works, but I really don't know why or how
- Whitestrake 3y agoHeck, you could extend it with Caddy Docker Proxy and go right back to the labels-as-configuration method. https://github.com/lucaslorentz/caddy-docker-proxy https://github.com/lucaslorentz/caddy-docker-proxy I actually do this, because I kinda like having the proxy config right next to the app config in my Compose file, but I also dislike how much manual configuration Traefik needs. Downside is you need to know how to write Caddyfile (easy enough) and then also know how to write labels so CDP translates them into the correct Caddyfile (also easy enough, but could be annoying if you're learning both at the same time). Upshot is that once you know how it translates and you know what you need to write, it works just like Traefik but with just two labels, and I think that's pretty neat. Caddy can support a surprising amount of weird and wonderful configurations, too.
- jhot 3y agoI do this at home. The labels are generally much simpler than traefik. labels: caddy: subdomain.${DOMAIN_NAME} caddy.reverse_proxy: "{{upstreams 8000}}"