Welcome! Log In Create A New Profile

Advanced

Re: Problem with rewrite or internal redirection cycle

Maxim Dounin
July 19, 2012 10:30AM
Hello!

On Wed, Jul 18, 2012 at 11:55:49AM -0400, drakerc wrote:

> Hello
>
> I have recently moved my website from Litespeed to nginx. I had to
> change some lines in my PHP script to use x-sendfile function and
> because of it I also had to change my nginx config. Unfortunately, when
> I'm executing my PHP script, I receive 500 Internal Server Error. My
> error.log says:
>
>
> 2012/07/18 17:39:52 [error] 23510#0: *20011855 rewrite or internal
> redirection cycle while internal redirect to "/index.php", client:
> 31.175.62.69, server: modbase.pl, request: "GET [...]
>
> I'm not sure what's causing this problem and how to fix it and I really
> need your help.

Your config with your script produce an infinite loop. Most likely
it's due to fact that after X-Accel-Redirect request ends up in
location /, and then redirected to /index.php as file isn't found,
and then again after X-Accel-Redirect request ends up in location
/ and so on.

> location / {
> client_max_body_size 1024m;
> try_files $uri $uri/ /index.php?q=$uri&$args;

[...]

> location /downloads {
> internal;
> }

[...]

> My PHP script snippet that uses x-sendfile:
>
> $filename_directoo = '/'.$cat_dir.'/'.$file_url;
> header("X-Accel-Redirect:".$filename_directoo);
> header('Content-Disposition: attachment; filename="'.$filename.'"');

It looks like "location /downloads" was added to avoid the above
loop, but you don't refer it in X-Accel-Redirect.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Problem with rewrite or internal redirection cycle

drakerc July 18, 2012 11:55AM

Re: Problem with rewrite or internal redirection cycle

Maxim Dounin July 19, 2012 10:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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