Welcome! Log In Create A New Profile

Advanced

Re: How to edit url and pass forward to wsgi?

Thomas Nyberg
September 03, 2015 08:42AM
Thank you very much for the response. It's working now. I didn't realize
that the regular expressions needed anchoring. I'm used to regular
expressions where '.*' is needed for the functionality you refer to.

On a related note, is there some way to log the location choices that
are made? I tried using a debug logging mode, but it was far too
low-level (on the level of memory allocations). Of course I could have
the routes' outputs go to certain files to figure it out, but if there
was a way to log something like "taking route
`/staging/doc/.*/info/cat`" it would make things much easier.

Thanks for the help!

On 09/03/2015 03:44 AM, Francis Daly wrote:
> On Thu, Sep 03, 2015 at 12:44:09AM -0400, Thomas Nyberg wrote:
>
> Hi there,
>
>> location ~ /staging/dog/.*/info/cat {
>
> "~" means "regex match".
>
> You haven't anchored the regex, so a request for /staging/dog/x/info/cat
> will match this, but so will a request for /a/staging/dog/x/info/cat/b
>
>> directive in place, but put the following one before it, then get
>> "502 Bad Gateway":
>>
>> location ~ /dog/.*/info/cat {
>
> This also is matched by a request for /staging/dog/x/info/cat.
>
> For regex locations, first match wins. So this location is chosen to
> process this request.
>
>> Nothing else was changed. The route is different, the port is
>> different. Why would this affect the other one? Is it that I'm
>> somehow "breaking" out and _then_ matching the other one?
>
> No. Your request matches the first regex location, so uses the first
> regex location.
>
> Possibly you want
>
> location ~ ^/dog/.*/info/cat
>
> or
>
> location ~ ^/dog/.*/info/cat$
>
> or maybe just
>
> location ^~ /dog/
>
> depending on what the full plan is.
>
>> I.e. I want to _not_ leave the location box once I've matched.
>> Is this possible?
>
> Yes, it's what you are already doing.
>
> You're just not in the location block you think you are in.
>
> http://nginx.org/r/location
>
> f
>

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to edit url and pass forward to wsgi?

Thomas Nyberg September 03, 2015 12:46AM

Re: How to edit url and pass forward to wsgi?

Francis Daly September 03, 2015 03:46AM

Re: How to edit url and pass forward to wsgi?

Thomas Nyberg September 03, 2015 08:42AM

Re: How to edit url and pass forward to wsgi?

Francis Daly September 03, 2015 02:48PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready