Welcome! Log In Create A New Profile

Advanced

Re: location regex

November 02, 2016 07:30AM
On 02 Nov 2016, at 01:49, olat <nginx-forum@forum.nginx.org> wrote:

> Looks like there is a bug in the forum. 2 the same topics and the response
> ended up in the wrong thread, mixed up ;-)

Yes, the forum has some issues when answer come from the mailing list.

> Anyway, Thanks Igor for a quick response. Could you explain more why regex
> is not a good idea? I am asking about regex in the context of caching some
> of the requests on front-end proxy to speed up django app loading dynamic
> content where session is involved. Does it mean each of the filtered out
> requests we would like to cache, should duplicate the same location block?
>
>
> server {
> ...
>
> proxy_set_header Host myhost;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header X-Forwarded-Proto- $scheme;
>
> # catch only /appfoo* and /appbar*
> location ~ /app(foo|bar)* {
> proxy_pass http://ip;
> proxy_redirect http://ip $scheme://$server_name;
>
> proxy_cache $cache_zone_name;
> proxy_cache_key "$request_uri";
> ...
> proxy_cache_methods GET HEAD;
> proxy_cache_bypass $cache_refresh;
> proxy_no_cache $skip_cache;
>
> proxy_ignore_headers "Set-Cookie" "Vary" "Expires";
> proxy_hide_header Set-Cookie;
> }
> # everything else goes here
> location / {
> proxy_pass http://ip;
> proxy_redirect http://ip $scheme://$server_name;
> }
>
> Thanks in advance for help.

The regex locations are tested in order of their appearance.
The prefix locations match the longest match regardless of their order.
If you will have a lot of locations then prefix locations are much easier
to maintain: you can add, change and delete prefix locations without
worrying how this will affect other locations.


--
Igor Sysoev
http://nginx.com

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

Location regex

Mathew Davies October 27, 2009 08:30PM

Re: Location regex

Marcus Clyne October 27, 2009 09:00PM

Re: Location regex

Mathew Davies October 27, 2009 09:44PM

Re: Location regex

Marcus Clyne October 27, 2009 11:02PM

Re: Location regex

Michal Kowalski October 27, 2009 11:02PM

Re: Location regex

Igor Sysoev October 28, 2009 03:34AM

Re: Location regex

Mathew Davies October 28, 2009 10:56AM

Re: location regex

Igor Sysoev November 01, 2016 10:06AM

Re: location regex

olat November 01, 2016 06:49PM

Re: location regex

Igor Sysoev November 02, 2016 07:30AM

Re: location regex

Francis Daly November 03, 2016 02:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 243
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