News for hackers. Stuff that matters.
Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by KronisLV on Tuesday February 27, 2024 @12:38PM (#39526924)
> The biggest thing is automatic HTTPS without having to install/configure anything but the base server, but even configuration is easier than other options.

I largely agree with this, but it's not like there's a huge gap between Caddy and Apache with mod_md (https://httpd.apache.org/docs/2.4/mod/mod_md.html) or even Nginx with certbot (https://www.digitalocean.com/community/tutorials/how-to-secu...), at least for HTTP-01 challenges.

Personally I think that Caddy v1 configuration was a little bit nicer than the current versions, but honestly it's a cool web server and I see its popularity continuing to rise in the future!

Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by mhitza on Tuesday February 27, 2024 @02:01PM (#39528115)
A few years ago I tweaked an Apache config to the most minimal set of modules and configs that I needed for my project. I considered this module as well, however it couldn't use the certificate when issued/renewed without a restart[1]. Based on the current docs, that still seems to be the case. Whereas with Caddy, and other software that (I assume) use the same underlying libraries, like gotosocial, I start the service and it does it all.

I'm still an Apache/nginx user, but certificates that require no configuration are the selling point of Caddy for me (and I use it on two very small projects because of that).

[1] Which meant that I had to write some sort of automation that detected the reissue and restart Apache (and set up appropriate systemd service/timers, limited user permissions to only allow passwordless restart, etc). In the end I kept certbot (which I wanted to get rid off) and let it manage the certificate (DNS challenge) and Apache restart. I'm open to a suggestion on how this can be done in a minimal way and requiring no supervision after.

Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by KronisLV on Tuesday February 27, 2024 @03:50PM (#39529726)
For my own needs, I did something a bit naughty: scheduled restarts, since in my particular use case a dozen seconds of downtime here or there don't really matter.

For something more precise, there is MDMessageCmd (e.g. listen for "renewed" and trigger reload; probably a short Bash script). Reload instead of restart should also be less disruptive.

Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by mhitza on Wednesday February 28, 2024 @07:26AM (#39536994)
The automatic restart could definitely work (since graceful is enough and doesn't cause downtime). Though it's better if unnecessary stuff isn't done on the server.

The other option with MDMessageCmd, would require (on a SELinux distro) to grant Apache command exec permissions, among other tweaks.

What would be better in this case were if Apache could message via DBus these events and I could make a dbus service that listens and restarts accordingly (better execution isolation).

If Apache would do internally the certificate swap, now that would be perfect.

Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by theteapot on Tuesday February 27, 2024 @01:00PM (#39527224)
Are you using Apache as a reverse proxy with SSL in front of containers?
Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by KronisLV on Tuesday February 27, 2024 @03:34PM (#39529493)
Yep, sometimes, when I'm not using Kubernetes with a Traefik or Nginx ingress.

That's actually how most of my personal and homelab stuff runs, with Docker Swarm due to how lightweight and simple it is. There, Apache actually works better for me since if I have 10 different domains configured and only 9 resolve (e.g. containers not running yet) then something like Nginx would complain about a non existent domain and crash the whole thing, whereas Apache would serve the 9 other domains and eventually proxy the 10th as well, instead of just returning an error.

I did tune Apache a little bit, in that I disabled .htaccess to avoid too much I/O (now the config is more like nginx.conf), though also sometimes add other modules, like mod_security (simple WAF) or mod_auth_openidc (Relying Party, so using OIDC wouldn't make me insane), as well as PHP-FPM if I ever need PHP in a particular container.

Nginx is still better for serving static files in general (e.g. packaged SPA), Traefik for HTTPS, but Apache is generally okay at most things.

Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by francislavoie on Tuesday February 27, 2024 @04:53PM (#39530599)
> Personally I think that Caddy v1 configuration was a little bit nicer than the current versions

In what way? Caddy v1 config was very inflexible, so there were lots of things that were simply impossible to do with it. I think we struck a good balance of simplicity to expressiveness.

Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by yjftsjthsd-h on Tuesday February 27, 2024 @05:11PM (#39530839)
Being less flexible often makes simpler things simpler even as it makes hard things harder.
Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by francislavoie on Tuesday February 27, 2024 @05:20PM (#39530943)
Sure, but what's harder? I'm looking for examples.
Re:Deploying Web Apps with Caddy: A Beginner's Guide Caddy by yjftsjthsd-h on Tuesday February 27, 2024 @10:04PM (#39533447)
> mod_md

That actually does look like it'll be reasonable, but 1. it still requires that the user figure out how to enable mod_md and add the config to enable it, and 2. it's currently labeled "Status: Experimental", which https://httpd.apache.org/docs/2.4/mod/module-dict.html#Statu... describes as

> "Experimental" status indicates that the module is available as part of the Apache kit, but you are on your own if you try to use it. The module is being documented for completeness, and is not necessarily supported.

so it seems more like something that will eventually become a good alternative.

> Nginx with certbot

I'm fine with certbot, but there's a world of difference between "install this web server and tell it your URL starts with https://" vs "install the web server, install this other package, read the docs to configure the other package or run the setup script and follow the prompts".