1

Trying to get nginx to work with the X-Accel-Redirect header. I'm getting this error:

*24 rewrite or internal redirection cycle while internally redirecting to "/app/index.php", client: 127.0.0.1, server: project.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "project.dev" 

nginx site conf:

server { listen 80; server_name project.dev; root /www/project; location ^~ /f/ { internal; alias /www/project/files/; } location / { try_files $uri /app/index.php$is_args$args; } include php.conf; include apache.conf; } 

/www/project/app/index.php

<?php header('X-Accel-Redirect: /f/image.jpg'); exit; 

I added ^~ to the location block, because I thought that would terminate the matching of location blocks, and therefor solve this. This might be a misunderstanding from my part.

Any idea how to fix this?


Update with php.conf and apache.conf

php.conf:

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 

apache.conf:

# deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } 
4
  • This configuration works fine for me. Please provide the contents of php.conf and apache.conf since they may be interfering. Commented Feb 7, 2013 at 21:10
  • @mgorven Updated Q Commented Feb 7, 2013 at 21:13
  • Does the PHP page display if you remove the X-Accel-Redirect and just echo something? What URL are you accessing in the browser? What happens if you specifically access /app/index.php? Commented Feb 7, 2013 at 21:17
  • To be clear: you're hoping that when you go to the root in a browser, /www/project/files/image.jpg is served? Commented Feb 8, 2013 at 16:28

2 Answers 2

0

You haven't told nginx what index file to look for.

Try adding

index index.php; 

After the root directive.

1
  • I've done that in my nginx.conf: index index.html index.htm index.php; Commented Feb 13, 2013 at 11:29
0

Looks like I failed to restart my nginx server. When I returned to this a couple of days later, it was suddenly working, and I realized it must be after a reboot. Sorry for wasting your time.

Now if I only could make it send the correct Content-type header..

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.