Weird behavior when checking the existence of a cookie
Francis Daly
francis at daoine.org
Tue Sep 30 22:24:47 UTC 2014
On Fri, Sep 26, 2014 at 02:02:12PM -0300, Marcello Rocha wrote:
Hi there,
> I have this location block:
>
> location /some_path/ {
> # this sets the mobile_rewrite variable based on a regex against
> the user_agent
> include /etc/nginx/mobile;
>
> # This is where the trouble lies. =/
> if ($cookie_mobileBypassDaily = yes_please) {
> set $mobile_rewrite do_not_perform;
> }
This is an "if" inside a "location" which does something other than
"return" or "rewrite...last".
Generally, that's a thing to avoid.
http://wiki.nginx.org/IfIsEvil
Can you move those three lines outside of the "location" block?
Actually: I suspect that the included file also does "if", so you may
want to move that outside of the "location" block too.
>From your description, they both do not depend on the particular request,
so it may be ok to have them both at server{} level (and applying to
all requests).
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list