Welcome! Log In Create A New Profile

Advanced

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

Daniël Mostertman
February 18, 2015 12:04PM
Hi again,

And ugh, yet again realising what I did wrong right after hitting "send":

Daniël Mostertman schreef op 18-2-2015 om 17:57:
> tl;dr: I want do have an add_header inside an if {}. nginx 1.7.10
> won't let me.
Because I didn't put the if inside a location.

> According to both http://wiki.nginx.org/IfIsEvil and
> http://nginx.org/en/docs/http/ngx_http_headers_module.html (see
> Context of add_header), it should be allowed inside an if.
> But yet:
>
> root:~# nginx -t
> nginx: [emerg] "add_header" directive is not allowed here in
> /etc/nginx/sites-enabled/webtv-test:37
> nginx: configuration file /etc/nginx/nginx.conf test failed
> root:~#
>
> What am I doing wrong, if anything? And if I can avoid using "if" like
> that, I'd obviously prefer that.

Answering my own question: "add_header" can only be inside an "if"
that's inside a "location".
I have no "location" for the root, so I figured it could be inside "server".

Daniël

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

'add_header' no longer allowed inside 'if', even though document says it is?

Daniël Mostertman February 18, 2015 11:58AM

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

Daniël Mostertman February 18, 2015 12:04PM

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

Valentin V. Bartenev February 18, 2015 12:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 272
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready