Nginx location - pass certain content type to apache backend

Hi all,

I have following configuration

    location ~* 

^.+.(jpg|png|mp3|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js)$
{
root /data/www/domain.com/htdocs;
access_log off;
expires max;
add_header Last-Modified: $date_gmt;
}

    location /get/ {
    proxy_pass http://domain-dev;
    }

How do I tell nginx to ignore serving jpg|png|mp3 for /get
location and pass them to apache instead?

Thanks

Posted at Nginx Forum:

On Sat, May 15, 2010 at 05:01:25PM -0400, dannym wrote:

    location /get/ {
    proxy_pass http://domain-dev;
    }

How do I tell nginx to ignore serving jpg|png|mp3 for /get location and pass them to apache instead?

There are two ways:

  1. forbid testing regex after static “/get/…” matched:

      location ^~ /get/ {
    
  2. add second regex:

      location ~ ^/get/.\.(jpg|png|mp3)$ {
          proxy_pass http://domain-dev;
    
      location ~* ^.+\.(jpg|png|mp3|ico|css|zip ...
          ...
    
      location /get/ {
          proxy_pass http://domain-dev;
    

See also:

http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration


Igor S.
http://sysoev.ru/en/

Exact match is working. Thanks, Igor.

Posted at Nginx Forum: