POST not allowed (was Re: Location problems)

Igor Clark igor at pokelondon.com
Mon Mar 31 22:14:27 MSD 2008


Hi Igor,

Looking back, it seems I missed the patch you attached to this email!  
Sorry about that.

I see you integrated this change in 0.6.27:

>    *) Change: now a request method is not changed while redirection  
> to a
>       named location via an "error_page" directive.

I've tried to run a similar site on 0.6.29 with the same PHP framework  
and an almost identical nginx vhost config (attached as  
nginx.location.conf), using the "location" style you described,  
including "error_page 404 405 = @...". I haven't converted all the  
"rewrites" to "locations" yet, but there's no "if (! -f  
$request_filename" or similar.

I'm getting some strange and intermittent errors, including apparent  
upstream timeouts, and seemingly random Bad Request errors on what  
should be simple HREF links. I haven't been able to make a solid set  
of steps to reproduce the Bad Request error yet, so the main problem  
is as follows:

POST to /admin/posts/add/

> 2008/03/31 16:10:33 [debug] 32073#0: *10 socket 23
> 2008/03/31 16:10:33 [debug] 32073#0: *10 epoll add connection: fd:23  
> ev:80000005
> 2008/03/31 16:10:33 [debug] 32073#0: *10 connect to  
> 192.168.142.2:9400, fd:23 #12
> 2008/03/31 16:10:33 [debug] 32073#0: *10 http upstream connect: -2
> 2008/03/31 16:10:33 [debug] 32073#0: *10 event timer add: 23:  
> 60000:90483751
> 2008/03/31 16:10:33 [debug] 32073#0: *10 post event B7E4D10C
> 2008/03/31 16:10:33 [debug] 32073#0: *10 post event B7E4D0A4
> 2008/03/31 16:10:33 [debug] 32073#0: *10 delete posted event B7E4D0A4
> 2008/03/31 16:10:33 [debug] 32073#0: *10 http upstream check client,  
> write event:1, "/admin/posts/add/"
> 2008/03/31 16:10:33 [debug] 32073#0: *10 http upstream recv(): -1  
> (11: Resource temporarily unavailable)
> 2008/03/31 16:10:33 [debug] 32073#0: *10 delete posted event B7E4D10C

At this point, the browser hangs, and other requests for JS files  
which the browser apparently sent at the same time (AJAX?) start to  
fail too:

> 2008/03/31 16:10:34 [debug] 32073#0: *13 http finalize request: 0, "/ 
> scripts/admin/external/jquery/jquery.dimensions.js?"
> 2008/03/31 16:10:34 [debug] 32073#0: *13 set http keepalive handler
> 2008/03/31 16:10:34 [debug] 32073#0: *13 http close request
> 2008/03/31 16:10:34 [debug] 32073#0: *13 http log handler
> 2008/03/31 16:10:34 [debug] 32073#0: *13 run cleanup: 082D9760
> 2008/03/31 16:10:34 [debug] 32073#0: *13 file cleanup: fd:25
> 2008/03/31 16:10:34 [debug] 32073#0: *13 free: 082D9090, unused: 1453
> 2008/03/31 16:10:34 [debug] 32073#0: *13 event timer add: 22:  
> 1000:90424947
> 2008/03/31 16:10:34 [debug] 32073#0: *13 free: 082B2BD0
> 2008/03/31 16:10:34 [debug] 32073#0: *13 free: 082AB588
> 2008/03/31 16:10:34 [debug] 32073#0: *13 hc free: 00000000 0
> 2008/03/31 16:10:34 [debug] 32073#0: *13 hc busy: 00000000 0
> 2008/03/31 16:10:34 [debug] 32073#0: *13 http keepalive handler
> 2008/03/31 16:10:34 [debug] 32073#0: *13 malloc: 082AB588:1024
> 2008/03/31 16:10:34 [debug] 32073#0: *13 recv: fd:22 -1 of 1024
> 2008/03/31 16:10:34 [debug] 32073#0: *13 recv() not ready (11:  
> Resource temporarily unavailable)
> 2008/03/31 16:10:34 [debug] 32073#0: *13 post event B7E82070
> 2008/03/31 16:10:34 [debug] 32073#0: *13 post event B7E4D070
> 2008/03/31 16:10:34 [debug] 32073#0: *13 delete posted event B7E4D070
> 2008/03/31 16:10:34 [debug] 32073#0: *13 http empty handler
> 2008/03/31 16:10:34 [debug] 32073#0: *13 delete posted event B7E82070
> 2008/03/31 16:10:34 [debug] 32073#0: *13 http keepalive handler
> 2008/03/31 16:10:34 [debug] 32073#0: *13 recv: fd:22 855 of 1024
> 2008/03/31 16:10:34 [debug] 32073#0: *13 malloc: 082B2BD0:636
> 2008/03/31 16:10:34 [debug] 32073#0: *13 event timer del: 22: 90424947
> 2008/03/31 16:10:34 [debug] 32073#0: *13 generic phase: 0


When I hit "stop" on the browser I get this:

> 2008/03/31 16:10:56 [info] 32073#0: *13 client closed prematurely  
> connection, so upstream connection is closed too while sending  
> request to upstream, client: 82.108.140.18, server: server_name,  
> request: "GET /scripts/admin/uploader.js HTTP/1.1", upstream:  
> "fastcgi://192.168.142.2:9400", host: "server_name", referrer: "http://server 
> _name/admin/posts/add/"


The same PHP code works fine using either 0.5.31 or 0.6.29 and the old- 
style config (with lots of "if (! -f..").

At present I don't really have much idea whether it's a problem with  
the patch, with my config, or some problem with the PHP server or PHP  
code which is only appearing under this circumstance, so I'd be very  
grateful for any thoughts you have on the matter!

Best wishes,
Igor


===========
Attachments:

nginx.location.conf - doesn't work, causes problem described.
nginx.if.conf - works with 0.5.35 and 0.6.29.
nginx.debug.log - debug output from when I press the button which  
submits the POST until I press the browser "stop" button.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx.location.conf
Type: application/octet-stream
Size: 2107 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20080331/4bf9ed49/attachment.obj>
-------------- next part --------------



-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx.if.conf
Type: application/octet-stream
Size: 1286 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20080331/4bf9ed49/attachment-0001.obj>
-------------- next part --------------



-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx.debug.log
Type: application/octet-stream
Size: 165151 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20080331/4bf9ed49/attachment-0002.obj>
-------------- next part --------------



===========

On 10 Mar 2008, at 10:28, Igor Sysoev wrote:

> On Mon, Mar 10, 2008 at 10:05:17AM +0000, Igor Clark wrote:
>
>> Thanks Igor. I just tried this and it allows it through, but it
>> appears to the upstream as a GET. It needs to be a POST as it has
>> multipart/form-data. Any thoughts?
>
> The patch. It will be included in 0.6.27.
>
>>>> [?]
>>>
>>> You do not need these rewrite's, use location's.
>>> The configuration is bigger, but it's much clearer and so it's
>>> scaleable:
>>> you can easy add new locations without being afraid to break some
>>> rewrite.
>>>
>>> However, you may need to use some rewrite's in these locations if
>>> you need
>>> to rewrite URI to pass into "location  ~ \.flv$" with changed URI to
>>> match
>>> common root.
>>>
>>> 		location = / {
>>> 			index		index;
>>> 	 		root		/path/to/public/financethemes;
>>> 			error_page	404 =	@phpapp;
>>> 		}
>>>
>>>> [?]







More information about the nginx mailing list