If you like, I can send you an example of the Caddyfiles, that I’m using (I used the import directive to split every service into its own Caddyfiles, you could just copy and paste everything in the same file). It will take a few hours until I get home, though.
But basically you can just put every subdomain and it’s target in a separate block and the add some things globally (e.g. passing the original IP, switching off the admin API of Caddy,…)
Something like this should work:
admin off servers { client_ip_headers X-Forwarded-For X-Real-IP } app.example.com { reverse_proxy 127.0.0.1:8080 } app2.example.com { reverse_proxy 127.0.0.1:8081 } api.example.com { reverse_proxy 127.0.0.1:8080 header { Access-Control-Allow-Methods "GET, OPTIONS" Access-Control-Allow-Origin "*" } }
irmadlad@lemmy.world 4 months ago
It looks like Elvith Ma’for@feddit.org has you headed in the right direction, so I won’t muddle the waters.
I meant to include this in my earlier comment, but Caddy has a built in caddyfile validator:
caddy fmt --overwrite /etc/caddy/Caddyfile caddy validate --config /etc/caddy/Caddyfile
Comes in very handy.
Profligate_parasite@lemmy.world 4 months ago
ooh I broke it as I was trying things and this was solid gold… thank you stranger!
irmadlad@lemmy.world 4 months ago
Anytime bro. Did you get it going?
Profligate_parasite@lemmy.world 4 months ago
ugh. no. Now caddy wont start… various errors… sometimes it says listening port 80, port 80 in use. This morning after reset and caddy fmt --overwrite, it says: Error: loading initial config: loading new config: http app module: start: listening on :443: listen tcp :443: bind: permission denied Error: caddy process exited with error: exit status 1