Weird behavior when checking the existence of a cookie

Marcello Rocha marcello.rocha at
Fri Sep 26 17:02:12 UTC 2014

Hi list, this is my first post here, so If I commit any blunder please let
me know.

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;

        if ($mobile_rewrite = perform) {
            return 302 $scheme://;
        # upstream/ to remove the /some_path/ part of the uri
        proxy_pass http://upstream/;

And now to the trouble at hand: if there is no cookie the proxy_pass is
executed rightly (ie. =>
http://upstream/thing). If the cookie exists the proxy_pass not only has
the some_path part of the url but it also has an extraneous slash (ie. => http://upstream//some_path/thing).

Why is this happening? What I'm doing wrong besides, maybe, everything? =)

Thanks for the help

*Marcello Rocha*
Pesquisa & Desenvolvimento

(11) 4084.1111 ou (xx) 4007.1547 [image: VAGAS] <>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list