Welcome! Log In Create A New Profile

Advanced

Re: Proxy pass location inheritance

Maxim Dounin
February 14, 2014 07:22AM
Hello!

On Thu, Feb 13, 2014 at 06:43:08PM +0000, Brian Hill wrote:

> Hello, we are using NGINX to serve a combination of local and
> proxied content coming from both an Apache server (mostly PHP
> content) and IIS 7.5 (a handful of third party .Net
> applications). The proxy is working properly for the pages
> themselves, but we wanted set up a separate location block for
> the "static" files (js, images, etc) to use different caching
> rules. In theory, each of the static file location blocks should
> be serving from the location specified in its parent location
> block, but instead ALL image requests are being routed to the
> root block.

[...]

> Three of the four conditions are working properly.
> A request for www.site.edu/index.php gets sent to 10.64.1.10:80/index.php
> A request for www.site.edu/image1.gif gets sent to 10.64.1.10:80/default.gif
> A request for www.site.edu/app1/default.aspx gets sent to 10.64.1.20:80/app1/default.aspx
>
> But the last condition is not working properly.
> A request for www.site.edu/app1/image2.gif should be sent to 10.64.1.20:80/app1/image2.gif.
> Instead, it's being routed to 10.64.1.10:80/app1/image2.gif, which is an invalid location.
>
> So it appears that the first server location block is catching
> ALL of the requests for the static files. Anyone have any idea
> what I'm doing wrong?

Simplified:

location / {
location ~ regex1 {
# regex inside /
}
}

location ~ regex2 {
# regex
}

The question is: where a request matching regex1 and regex2 will
be handled?

The answer is - in "location ~ regex1". Locations given by
regular expressions within a matching prefix location are tested
before other locations given by regular expressions.

--
Maxim Dounin
http://nginx.org/

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

Proxy pass location inheritance

brih February 13, 2014 01:44PM

Re: Proxy pass location inheritance

Maxim Dounin February 14, 2014 07:22AM

RE: Proxy pass location inheritance

brih February 17, 2014 03:56AM

Re: Proxy pass location inheritance

Francis Daly February 17, 2014 04:18AM

Re: Proxy pass location inheritance

Maxim Dounin February 17, 2014 08:14AM

RE: Proxy pass location inheritance

brih February 17, 2014 12:16PM

Re: Proxy pass location inheritance

Maxim Dounin February 17, 2014 12:32PM

RE: Proxy pass location inheritance

brih February 17, 2014 04:28PM

Re: Proxy pass location inheritance

Maxim Dounin February 18, 2014 07:14AM

RE: Proxy pass location inheritance

brih February 18, 2014 01:18PM

Re: Proxy pass location inheritance

Igor Sysoev February 19, 2014 02:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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