Skip to content

Add headers if not set. #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SamMousa opened this issue Jul 12, 2016 · 3 comments
Open

Add headers if not set. #60

SamMousa opened this issue Jul 12, 2016 · 3 comments

Comments

@SamMousa
Copy link

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.

@agentzh
Copy link
Member

agentzh commented Jul 15, 2016

@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.

@mkasimd
Copy link

mkasimd commented Apr 21, 2021

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.

@splichy
Copy link

splichy commented Oct 18, 2024

map cannot be used easily with ingress-nginx as it must be within the HTTP context. The same is true for the lua module, which would require using a custom config template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants