Posting to FastCGI in named locations

Hi there Igor,

I’m having real problems using PHP/FCGI, named locations and POST.
I’ve been through our previous discussions, all the mailing list and
the wiki and I just can’t work out what’s wrong, whether it’s a
configuration problem, a bug, or what.

I’ve tried to reduce to the bare minimum simple components to see how
to fix it, and it still happens.

nginx config:

location / {
index index.php;
error_page 404 = @phpapp;
}

location @phpapp {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/test.php;
fastcgi_param SCRIPT_URL $fastcgi_script_name; # for use in
particular PHP framework
include fastcgi_params;
}

Posting from /form.html:

to /blah, which is passed via FastCGI to test.php:

<?  print_r($_SERVER); ?>

When I try to POST, I get 405 Not Allowed.

Neither static_post nor post_to_static seem to be in place (nginx
0.6.31):

2008/05/15 14:54:44 [emerg] 11264#0: unknown directive “static_post”
in /usr/local/nginx-0.6.31/conf/nginx.conf:51
2008/05/15 14:54:56 [emerg] 11269#0: unknown directive
“post_to_static” in /usr/local/nginx-0.6.31/conf/nginx.conf:51

When I change the error_page directive as you suggested before, so
that “POST /blah” should route to @phpapp, like so:

error_page 404 405 = @phpapp;

the connection hangs and I get the attached debug output from nginx,
with the following error:

2008/05/15 15:23:44 [debug] 19370#0: *3 http upstream recv(): 0 (11:
Resource temporarily unavailable)

which seems strange, as other PHP requests work fine.

When I change back to a “normal” PHP setup, without named locations,
like this:

location ~ .php.*$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

the POST from /form.html to /test.php works as expected, and I haven’t
restarted or changed the PHP FCGI server in any way.

I’ve tried this for 0.6.27, 0.6.28, 0.6.29, 0.6.31. It happens on
Linux kernels version 2.6.9-5.ELsmp and 2.6.9-67.0.4.ELsmp.

Please could you let me know if you have any ideas about how to fix
this?

All our sites use this sort of rewrite strategy and would like to use
the “named location fallback” configuration approach, but this problem
just makes it impossible if we need to POST anything, which is often.

Many thanks,
Igor

Hiya, sorry to keep on about this!

Is there anything more I can provide, more detailed debug output or
anything, to help track this down?

Thanks,
Igor