rewrite or internal redirection cycle while internally redirecting to "/index.php"
adambenayoun
nginx-forum at nginx.us
Thu Dec 27 11:34:34 UTC 2012
Hello everyone,
I'm having some issue with X-accel and I'd be happy if someone could look
over my configuration file and let me know what I did wrong.
I am basically running nginx/1.2.5 with php-fpm 5.3.3 on Centos 5.5
I am running an application that is served using Zend Framework from
/var/www/domain/html/http
I have many files available for download from
/var/www/domain/html/files/projects/$id/$file_name ($id is anything ranging
from 1-999 and $file_name is a zip file).
I want to basically serve the zip files using X-Accel and bypass php-fpm.
In the application when I check if the file can be served or not - I added
this: header("X-Accel-Redirect: " . $file); in order to serve it using
X-Accel.
I also added this location in my config to serve the zip files using nginx
location /projects {
internal;
root /var/www/domain/html/files;
}
The problem is I get a 500 error and when I look at the log file - this is
what I can spot:
[error] 10274#0: *25 rewrite or internal redirection cycle while internally
redirecting to "/index.php"
This is the content of my domain.conf in /conf.d
server {
listen 80;
listen 443 ssl;
server_name domain.com;
ssl_certificate /etc/nginx/certs/www.domain.com.crt;
ssl_certificate_key /etc/nginx/certs/www.domain.com.key;
return 301 $scheme://www.domain.com$request_uri;
}
server {
listen 80;
listen 443 ssl;
server_name www.domain.com;
error_log /var/www/domain/logs/error_log warn;
ssl_certificate /etc/nginx/certs/www.domain.com.crt;
ssl_certificate_key /etc/nginx/certs/www.domain.com.key;
root /var/www/domain/html/http;
index index.php;
client_max_body_size 250m;
error_page 403 404 =404 /notfound;
include /etc/nginx/conf.d/domain.locations;
}
#### Content of domain.locations
if ( $request_uri ~ "^/index.php" ) {
rewrite ^/index.php(.*) $1 permanent;
}
location / {
rewrite ^/wanted/feed$ /feed?filter=wanted permanent;
try_files $uri $uri/ /index.php?$args;
}
location /min {
try_files $uri $uri/ /min/index.php?q=;
}
location /blog {
try_files $uri $uri/ /blog/index.php?q=$1;
}
location /apc {
try_files $uri $uri/ /apc.php$args;
}
location /projects {
internal;
root /var/www/domain/html/files;
}
location ~ \.php {
include /etc/nginx/fastcgi_params;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SERVER_NAME $http_host;
fastcgi_pass 127.0.0.1:9000;
}
location ~* ^.+\.(ht|svn|git)$ {
deny all;
}
# Static files location
location ~*
^.+\.(jpg|jpeg|gif|png|ico|css|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
expires max;
}
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,234501,234501#msg-234501
More information about the nginx
mailing list