location /static/ {
root /path/to/dir;
expires 30d;
access_log off;
}
location /static/ {
access_log off;
expires 30d;
root /path/to/dir;
try_files $uri @zipped;
}
location @zipped {
rewrite ^/static/(.*)\.(doc|docx|xls|xlsx)$ /static/$1.zip redirect;
}
curl -IL https://example.com/static/test.doc
HTTP/2 302
server: nginx
content-type: text/html
content-length: 138
location: https://example.com/static/test.zip
HTTP/2 200
server: nginx
content-type: application/zip
content-length: 29
expires: Thu, 15 Dec 2022 18:31:20 GMT
accept-ranges: bytes