Comment on Help? Caddy reverse proxy
irmadlad@lemmy.world 2 days ago
What does your caddyfile look like? I have a sneaking suspicion that you left the caddyfile as it comes installed, which indeed uses port 80 to deliver the Caddy success test. If you point your browser to the ip of your server, do you see the 'It Worked!" page that Caddy serves up?
Don’t sweat the complications. I know it’s frustrating. Full disclosure, it took me a while to ‘get’ Caddy. Once I did tho, it really is easy peasy. I actually found Cloudflare Tunnels/ZeroTrust easier to set up. I realize some have ‘concerns’ about Cloudflare, which is understandable.
Profligate_parasite@lemmy.world 2 days ago
elvith@feddit.org 2 days ago
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:
Profligate_parasite@lemmy.world 2 days ago
Thanks very much, this is really helpful… one thing I note is that I don’t know what “api.example.com” is … is that necessary to make this work or is it just an option? I haven’t mucked with API of Caddy at all…do I need to?
elvith@feddit.org 2 days ago
No, that’s just another hypothetical app that you’re using a reverse proxy for. I just included it to show how you can also set settings for a single subdomain/reverse proxy entry that isn’t used globally on all domains that get served. I used a hypothetical REST API that needs a CORS Header that other apps don’t need (or maybe serve themselves).
admin offdisables Caddy’s admin interface (which shouldn’t be public and if you’re using config files this usually isn’t needed. So just a bit of gardening)serverssets some general server options.and then I just inserted several blocks that each define a reverse proxy to a different app / backend to show that you can just dump them all in a single Caddyfile. And the last example to show that you can set specific settings only for a specific subdomain instead of globally. As I set headers mostly used by REST APIs, I just called that api.example.com instead of app3.example.com.
Profligate_parasite@lemmy.world 2 days ago
I’ve tried this caddyfile version and one above, for both, I get “Problem loading page. Secure connection failed. Internal error.” Oddly, I get the ‘welcome to caddy’ page directly at my IP but at my sub domain I get the error.
irmadlad@lemmy.world 2 days 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 2 days ago
ooh I broke it as I was trying things and this was solid gold… thank you stranger!
irmadlad@lemmy.world 2 days ago
Anytime bro. Did you get it going?