Setting response headers per file

Arnold Hendriks unilynx at gmail.com
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
configuration)

Eg. if I request http://127.0.0.1/attachment-12345 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
file)
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: <http://mailman.nginx.org/pipermail/nginx/attachments/20230106/6804ad7a/attachment.htm>


More information about the nginx mailing list