I run Caddy as a frontend proxy to varnish and as a backend proxy to php-fpm.
Caddy > Varnish > Caddy > PHP-FPM
Currently Caddy proxies everything to Varnish. My goal is to have Caddy serve static content from disk directly and use Varnish only to cache heavy PHP requests. Everything runs on the same VPS so using Varnish for static content does not benefit me very much here. I did some Googling but could not find a clear and concise answer. After some trial and error, I figured I could (abuse) the handle_errors directive for this.
Is the following configuration the recommended way to achieve what I want? It seems to work, but I’d rather be sure than run into issues in the long term.
Just for fun, if you use JSON (we haven’t exposed this in Caddyfile… yet?) the file server has a pass_thru option that will go on to the next handler if the file isn’t found: Modules - Caddy Documentation
But yeah I think what Francis posted is the bet way to do it.