Forum: NGINX location into location doen't work as expected

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniele M. (Guest)
on 2009-04-07 19:13
(Received via mailing list)
Hi all,

I've the following location configuration that doesn't work as expected
(i symplified my configuration with return value instead of rewrite):

location ^~ /image/ {
   location ^~ /image/(halfcol|medium|thumb)/ {
      return 402;
    }
    location ^~ /image/ {
      return 403;
    }
}

if i tried to get a /image/halfcol/something i expected to received a
402 return code.

$ HEAD http://localhost/image/halfcol/pippo.jpg | head -n1
403 Forbidden

I got a 403 instead :(

Thanks in advance
Daniele
Igor S. (Guest)
on 2009-04-07 19:20
(Received via mailing list)
On Tue, Apr 07, 2009 at 05:04:40PM +0200, Daniele M. wrote:

>      return 403;
>    }
> }
>
> if i tried to get a /image/halfcol/something i expected to received a
> 402 return code.
>
> $ HEAD http://localhost/image/halfcol/pippo.jpg | head -n1
> 403 Forbidden
>
> I got a 403 instead :(

The "^~" is not regex, conversely it disables to run regex, therefore:

   location /image/ {
       return  403;
   }

   location ~ ^/image/(halfcol|medium|thumb)/ {
       return  402;
   }
This topic is locked and can not be replied to.