Random file/image

Hi, I wonder if there is a way to have Caddy serve a random image file every time a fixed url is used, for example https://my.dom.com/image/image-of-the-day/

It is of course possible to use PHP or such, but it adds a layer that perhaps is unnecessary.

Thanks.

No, not with vanilla Caddy. But it would be trivial to implement with a plugin.

Thanks for the quick response. I don’t know golang, so I’ll do a PHP version instead. Does Caddy support X-SendFile header?

You can intercept proxy (and php_fastcgi, which extends reverse_proxy) responses and handle them however you want, including using the X-SendFile header to instruct Caddy to serve static files. See reverse_proxy (Caddyfile directive) — Caddy Documentation and the X-Accel-Redirect example which does the same thing.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.