To add a certain HTTP header to a file, create a server.headers file in /data/web/nginx, containing the following snippet:

If you want to do the same using a regex of all files that should have this additional header, that’s possible too:

Or even on all files:

If you want to override, for example the /media/ location but also other used locations in /etc/nginx/magentoX.conf, you must use an other regex then the already defined location block in our Magento Nginx configs:

Use the following in the /data/web/nginx/server.headers configuration file:

And don’t forget to change the domain name in the above example.

You could add more file extensions if you want.

Keep in mind

  • It is not possible in Nginx to add locations twice. Only the first location in the configuration file takes presence. This is because Nginx config works on a per request base.
  • Don’t use a colon (:) when adding headers. This will result in inconsistent results in different browsers.
11