add_header is not working in certain locations
francis at daoine.org
Thu Aug 14 17:16:55 UTC 2014
On Thu, Aug 14, 2014 at 10:16:43AM -0400, bodomic wrote:
> Actually, the second problem is described in this document too, I think I
> should re-read it every time I want to use IF.
"if" is fine.
It is only "if inside location" which needs care.
My general guideline is:
do "return ..."; or
do "rewrite ... last"; or
don't do it without understanding it.
> In my example (before posting it here) I've dropped the second IF in the
> same location without much thought.
> That's why it worked for you. That's why it worked in a separate location -
> I didn't move a second IF there, and again, did not pay enough attention to
Ah, right. Yes, it is always best to create a scratch system with a
small config that reliably shows the problem you encounter (and which
contains no private information), and then copy-paste exactly what is
in the scratch system.
That way, everyone testing things is looking at the same thing.
(And the "nginx -V" output can be useful too, in case there are version
or compile-time differences which matter.)
> So, the problem was the second IF in the same location.
I'd say that the problem was using "if" inside "location" without
understanding the nginx quirks.
Two or three "if"s might have been ok. One might have caused things not
to work as you wanted.
Francis Daly francis at daoine.org
More information about the nginx