1. Caddy version (caddy version
):
v2.4.0-beta.1
2. How I run Caddy:
Download binary from github releases page and caddy run
a. System environment:
___ _ _ _ __ ___ _ _ _
/ _ \ __| |_ __ ___ (_) __| | \ \/ / | | | || |
| | | |/ _` | '__/ _ \| |/ _` | \ /| | | | || |_
| |_| | (_| | | | (_) | | (_| | / \| |_| |__ _|
\___/ \__,_|_| \___/|_|\__,_| /_/\_\\___/ |_|
Welcome to Armbian 21.02.1 Buster with Linux 5.4.94-odroidxu4
System load: 1% Up time: 23:10 Local users: 2
Memory usage: 10% of 1.94G IP: 192.168.0.24
CPU temp: 37°C Usage of /: 2% of 234G
b. Command:
caddy run
d. My complete Caddyfile or JSON config:
Caddyfile
http://localhost:8080 {
reverse_proxy localhost:80
}
As you can see im up to quite some complex stuff
3. The problem I’m having:
I want to use Caddy as a web server because I like how its easily extensible, portable, and it manages the ACME renewals for me
However for my use case, I also need 3 capabilities:
- Active health checks against upstream servers & upstream server health states (not 100% needed, but nice to have)
- Ability to handle requests differently depending on whether the upstream server is “healthy” or not.
- Ability to cache HTTP responses from upstream servers, store them on disk, and respond with cached version.
I’m pretty sure Caddy already has 1. and 2. However it looks like 3. is in progress: GitHub - caddyserver/cache-handler: Distributed HTTP caching module for Caddy
4. Error messages and/or full log output:
N/A
5. What I already tried:
First I tried doing this with nginx but I was unable to get it to work perfectly.
I already tried building with the 3rd party module: GitHub - sillygod/cdp-cache: a caddy 2 proxy cache plugin but it had a lot of issues. I had to update some dependencies and fix a couple bugs to get it to run at all without crashing. It was often failing to serve responses or panic-ing on nil pointers, and I never observed it actually serving from cache when the upstream was down. Nail in the coffin was when I tried to add debug logging, I was unable to get any visible output from the program, even after trying to manually open a file and append lines to it. Maybe this is because I’m impatient and unfamiliar with xcaddy build process or because I made a stupid mistake or something but I just gave up cuz I don’t want to spend another whole day on this.
In the end I shoddily hacked together my own custom solution which works fine but I feel like it should not be required for this.
6. Links to relevant resources:
I cant post links because im a new user RIP ME
Basically I just wanted to ask, is caching out of scope for Caddy? I realize caching is complex and difficult so that might explain why its not present in Caddy after all these years.
Yes I realize my proposed solution of utilizing a cache to serve static files & separate static from dynamic content as a part of a web application (like CDN+API) is kinda silly. Basically I was talking about making the API (dynamic part) serve everything and having the reverse proxy cache only the static files, thus allowing site to stay up when API goes down. This is just because its most convenient for the application I am serving. Yes I realize I can craft some custom set up to manually copy the static files from the app server’s webroot folder to the reverse proxy server and set up different routes for serving static files + reverse proxying the dynamic content. It’s just more of a pain in the butt and caching would feel more clean and nice. So this is just my 2c in the jar for caching support.
Yeas I realize the irony of asking for something wile at the same time stating that im too lazy to figure it out myself…