headers-more-nginx-module
headers-more-nginx-module copied to clipboard
Add headers if not set.
Currently this module adds support for a combined set/add which overwrites or adds a header, meaning the value of the header is always changed.
It would be great if it could also offer a set/skips function which sets if not present and skips otherwise.
@SamMousa Patches welcome. BTW, such requirements can be easily and efficiently done via the ngx_http_lua module:
https://github.com/openresty/lua-nginx-module/
That's why I'm reluctant to develop more and more such little things myself in this simple module.
Another way to achieve that might be through a map, e.g. something like this:
map $sent_http_referrer_policy $referrer_policy {
"" "strict-origin-when-cross-origin";
default $sent_http_referrer_policy;
}
....
more_set_headers "Referrer-Policy: $referrer_policy";
Certainly, a short more_set_headers -i as in #65 offers significanlty better maintainability and readability, but the above solution should work too.