Location regex issue

Hi list,

Facing a difficulty here,

I have the following location config:

location ~* (^/browse/$) {

And this seems to catch URls like /browse/?page=35 and similar.

In my understanding the $ (end of line) symbol should make this location
work only for /browse/ and nothing more… or am I wrong?

Thanks, Boyko

On Fri, Apr 15, 2011 at 4:12 PM, Boyko Y. [email protected]
wrote:

In my understanding the $ (end of line) symbol should make this location work
only for /browse/ and nothing more… or am I wrong?

anything past ? (and ? itself) is argument hence not checked when
matching location block.

On Apr 15, 2011, at 12:18 PM, Edho P Arief wrote:

matching location block.
Got u, thanks!

Then how am I supposed to achieve what I’m after? I need to make this
location work for /browse/ only and not for /browse/?args

Boyko

On Fri, Apr 15, 2011 at 4:23 PM, Boyko Y. [email protected]
wrote:

anything past ? (and ? itself) is argument hence not checked when
matching location block.

Got u, thanks!

Then how am I supposed to achieve what I’m after? I need to make this location
work for /browse/ only and not for /browse/?args

Add a check for $args.

Something like

if ($args == ‘’) { }

(I don’t remember exact syntax. Please check nginx wiki for more detail)

Hi,

Its:

        if ($args = "") {
stuff..
        }

Case solved,

Thanks a lot!

Boyko

On Fri, Apr 15, 2011 at 12:39:39PM +0300, Boyko Y. wrote:

Hi,

Its:

        if ($args = "") {
stuff..
        }

location = /browse/ {
if ($args != “”) {
return 404;
}

}


Igor S.

Thanks Igor,

Actually it was about caching - I needed to cache /browse/ only and not
/browse/?stuff

I used proxy_no_cache $args to make sure cached response wont be used
when $args are present. Seems to work well, logging only MISSed
responses, no cache HITs.

Boyko

Guys,

Further issue:

I tried to use around 2000 pages in the same location block like this:

location ~* (^/browse|^/page2|^/page3|… etc ^/page2000) {

And of-course I’m getting:

nginx: [emerg] too long parameter

Can I catch all these pages with a single location directive or I should
separate them in different locations? Also, what is the allowed size for
location parameter?

Boyko

On Fri, Apr 15, 2011 at 01:18:52PM +0300, Boyko Y. wrote:

Thanks Igor,

Actually it was about caching - I needed to cache /browse/ only and not
/browse/?stuff

I used proxy_no_cache $args to make sure cached response wont be used when $args
are present. Seems to work well, logging only MISSed responses, no cache HITs.

location = /browse/ {
proxy_cache_bypass $args;
proxy_no_cache $args;

}


Igor S.

On Fri, Apr 15, 2011 at 02:12:26PM +0300, Boyko Y. wrote:

nginx: [emerg] too long parameter

Can I catch all these pages with a single location directive or I should
separate them in different locations? Also, what is the allowed size for location
parameter?

You should not use regex location if you can avoid them.

location = /browse {

}

location = /page2 {

}

etc.


Igor S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs