Hello!
On Mon, Jun 29, 2009 at 01:00:00PM -0400, meto wrote:
} include php_support; if ( !-e $request_filename ) { # rewrites rewrite ^/avatar/(.*)\.png /avatar/index.php?user=$1 last; .... some rewrites .... rewrite ^/index\.php/(.*) /index.php?$1; # end rewrites }
I was able to reproduce coredump with the following reduced
config:
location / {
set $true 1;
if ($true) {
# fastcgi_pass here
fastcgi_pass 127.0.0.1:9000;
}
if ($true) {
# no handler here
}
# and no handler here
}
It does happily coredumps on 0.7.59 though. Just for completeness
I’ve tested 0.7.0 - it coredumps too. No idea why 0.7.59 works
for you.
The problem is that first matching if() installs fastcgi handler
for request, while actual processing takes place in context of
last matching if() (second in the example) and there is no
required fastcgi configs in this context.
Fix is to explicitly use break in if with fastcgi_pass to avoid
further rewrite processing, i.e.:
location / {
set $true 1;
if ($true) {
# fastcgi_pass here
fastcgi_pass 127.0.0.1:9000;
# break to avoid coredump
break;
}
if ($true) {
# no handler here
}
# and no handler here
}
It’s not clear for me how to fix code without breaking
more-or-less correct configs using if’s, so probably it’s a good
idea to wait for Igor’s return from vacation.
include settings; }
location ^~ /phpmyadmin {
#root /usr/share/xcache/admin;
location ~ /.ht {Why? I know that if is in rewrite module in docs but can’t we use it in other places?
Basically, if()'s are evil. Mostly due to the fact that nginx
configuration are declarative while if’s are imperative - and this
produces some nasty implementation details as in your problem.
In most situations it’s a good idea to avoid if’s. And test for
$request_uri/$request_filename means you can do so using
appropriate [regex] locations.
Do you suggest to use nested location rather than if() in that case? But still (and dont yell) - it worked before.
Yes, separate normal locations or nested ones is the way to go.
Maxim D.