Setting response headers per file

Arnold Hendriks unilynx at
Fri Jan 6 17:32:37 UTC 2023

Is there a way to have nginx serve up static content with custom headers -
but being able to set these headers per file (and not in the nginx

Eg. if I request I would like nginx to
use try_files to find the file 'attachment-12345' and serve it... but to
also look at 'attachment-12345.headers', take
Content-Type: application/mswordContent-Disposition: attachment;
name="abc.doc"Cache-Control: immutable
from that file and serve those headers. So nothing based on extension, and
each file can have its own headers.
(This would allow me to somewhat simulate a S3/Cloudfront based cache using
local disk... as S3 allows me to set a subset of HTTP headers for every
It would be even cooler if you could also put X-Accel-Redirect or Status:
301 headers in such a file and manage those in a 'static' way, but that's
beyond what I need now
With regards,Arnold Hendriks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list