Forum: NGINX nginx rewrite of certain mime types and request processing order

Posted by technoplague (Guest)
on 2012-11-05 12:01
(Received via mailing list)
Hi,

Having following nginx virtual host config:

#==============================================
upstream cf-domain {
    server unix:/data/www/prod/domain.com/cf/cf-domain.sock;
}

server {
    listen 10.0.0.1:80;
    listen 127.0.0.1:28005;
    server_name cf.domain.com;
    index index.php index.html;
    root /data/www/prod/domain.com/cf/htdocs;
    charset utf-8;
    access_log /data/www/prod/domain.com/cf/logs/frontend/access.log;
    error_log /data/www/prod/domain.com/cf/logs/frontend/error.log;
    client_max_body_size 8m;

    # get rewrite
    location /get/ {
        rewrite ^/get/([^/]+)/([^/]+)$ /get/index.php?contid=$1 last;
    }

    # static content
    location ~* \.(jpg|jpeg|gif|css|png|js|swf|ico|rar|zip)$ {
        expires max;
        access_log off;
        log_not_found off;
    }

    location / {
         try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass cf-domain;
        fastcgi_param SCRIPT_FILENAME 
$document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    }

    #include conf.d/cf.dirs.conf;
}
#==============================================

The problem is with processing order and /get location rewrite.
The request: http://cf.domain.com/get/68175/fingergr.swf returns 404,
instead by getting processed by /get location rewrite rule. This is 
because
swf is defined in (static content) location:

    # static content
    location ~* \.(jpg|jpeg|gif|css|png|js|swf|ico|rar|zip)$ {
        expires max;
        access_log off;
        log_not_found off;
    }

How is it possible to have /get location rewrite working together 
without
removing swf type from static content location?

Thanks,
T

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,232503,232503#msg-232503
Posted by Francis Daly (Guest)
on 2012-11-05 12:21
(Received via mailing list)
On Mon, Nov 05, 2012 at 06:00:32AM -0500, technoplague wrote:

Hi there,

>     }
>
> How is it possible to have /get location rewrite working together without
> removing swf type from static content location?

http://nginx.org/r/location

Note particularly the various things in between "location" and "uri",
and the example configurations D and E.

  f
--
Francis Daly        francis@daoine.org
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.