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.


Server A: Contains the root site and all sorts of images.
Server B: Contains applications in specific folders, and each folder has local 
images.

A simplified version of our server block:

upstream server_a {server 10.64.1.10:80;}
upstream server_b {server 10.64.1.20:80;}

server {
        listen 80;
        server_name     www.site.edu;
        #some irrelevant proxy, cache, and header code goes here

        # root location
        location / {
                proxy_cache_valid 200 301 302 304 10m;  #content changes 
regularly
                proxy_cache_use_stale error timeout updating;
                expires 60m;
                proxy_pass http://server_a;

                #this is the location for "static" content in the root. It is 
being called for ALL static files of these types
                location ~* \.(css|js|png|jpe?g|gif)$ {
                        proxy_cache_valid 200 301 302 304 30d;
                        expires 30d;
                        proxy_pass http://server_a;
                }
        }

        #.net locations on second server
        location ~* /(app1|app2|app3|app4) {
                proxy_cache_valid 0s; #no caching in these folders
                proxy_pass http://server_b;
                
                #location for static content in these folders. This is not 
working.
                location ~* \.(css|js|png|jpe?g|gif)$ {
                        proxy_cache_valid 200 301 302 304 30d;
                        expires 30d;
                        proxy_pass http://server_b;
                }
        }
}

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?

BH

_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to