index or try_files in reverse proxy

Igor Sysoev is at rambler-co.ru
Thu Aug 13 14:24:41 MSD 2009


On Thu, Aug 13, 2009 at 06:15:08AM -0400, meto wrote:

> Igor, unfortunately, your config doesn't work as expected. I'm using this config right now and it works for me:
> 
> location / {
>                 index index.html index.htm index.php;
> 
>                 try_files $uri $uri/ @proxy_backend;
>                 }
> 
>                 location ~ ^(.+\.php)(.*)$ {
>                 try_files $uri @proxy_backend;
> 
>                 fastcgi_pass    php;
> 
>                 fastcgi_index  index.php;
>                 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
>                 fastcgi_intercept_errors on;
>                 fastcgi_buffers 100 32k;
>                 fastcgi_read_timeout 600;
> 
>                 include fastcgi_params;
>                 }

Yes, this configuration works, since "/" is tested successfully by "$uri/".
Then the request is run inside "location /" and nginx looks for index files
and after it will find "/index.php", it does interanl redirect to
"/index.php", which is handled in "location ~ ^(.+\.php)(.*)$".


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list