Welcome! Log In Create A New Profile

Advanced

nginx rewrite of certain mime types and request processing order

November 05, 2012 06:00AM
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
Subject Author Posted

nginx rewrite of certain mime types and request processing order

technoplague November 05, 2012 06:00AM

Re: nginx rewrite of certain mime types and request processing order

Francis Daly November 05, 2012 06:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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