nginx location - pass certain content type to apache backend

Igor Sysoev igor at sysoev.ru
Sun May 16 12:49:30 MSD 2010


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

> 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 [b]/get[/b] 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 Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list