Did I got try_files wrong? and bad gateway 502
Igor Sysoev
is at rambler-co.ru
Wed Jul 8 17:33:37 MSD 2009
On Mon, Jul 06, 2009 at 05:37:27AM +0200, Tobias Lott wrote:
> Hey Folks
>
> I got a problem understanding try_files I guess.
>
> Got this as configuration :
>
> location = / { rewrite ^(.*)$ /shop/ redirect; }
>
> location / {
> proxy_pass http://backend:10060;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header Host $http_host;
> proxy_redirect off;
> proxy_connect_timeout 90;
> proxy_send_timeout 90;
> proxy_read_timeout 120;
> }
>
>
> Problem is that I cant "catch" all 404 and rewrite it
> to /shop/index.php but with "if" (which I shouldn't use cause of
> possible performance issues, Igor mentioned I think.)
>
> Doesn't work:
> try_files $uri $uri/ /shop/index.php;
> error_page 404 /shop/index.php;
>
> Works:
> if (!-f $request_filename) { rewrite ^(.*)$ /shop/index.php
> redirect; }
Have you tried this:
location = / { rewrite ^ /shop/ redirect; }
location / {
try_files $uri $uri/ /shop/index.php;
proxy_pass http://backend:10060;
...
}
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list