Static POST

The attached patch allows POSTs to non-existent files.
This allows POSTs in following configuration:

location / {
    error_page  404 = @fallback;
}

location @fallback {
    ...
}

I intended to include it in the next release.

What does this feature use for? Any scenarios?

2008/8/14 Igor S. [email protected]

On Fri, Aug 15, 2008 at 03:05:42PM +0800, Delta Y. wrote:

What does this feature use for? Any scenarios?

This configuration is replacement of ugly hack:

location / {

   if (-e $request_filename) {
       break;
   }

   proxy_pass  ...

}

Igor, this is great news, thank you. Will it be in the 0.6.x branch
release?

----- Original Message -----
From: Igor S. [email protected]
To: [email protected]
Sent: Fri, 15 Aug 2008 08:10:27 +0100 (BST)
Subject: Re: static POST

On Fri, Aug 15, 2008 at 03:05:42PM +0800, Delta Y. wrote:

What does this feature use for? Any scenarios?

This configuration is replacement of ugly hack:

location / {

   if (-e $request_filename) {
       break;
   }

   proxy_pass  ...

}

Superb. Thanks Igor.

----- Original Message -----
From: Igor S. [email protected]
To: [email protected]
Sent: Fri, 15 Aug 2008 09:50:26 +0100 (BST)
Subject: Re: static POST

On Fri, Aug 15, 2008 at 09:31:21AM +0100, Igor C. wrote:

Igor, this is great news, thank you. Will it be in the 0.6.x branch release?

Yes, it will be merged. The patch should be suitable for 0.6.x.

Hi Igor,

I’ve applied the patch to a fresh copy of 0.6.32 and I’m having the
same problems POSTing to named locations.

Configuration:

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;
}

Form:

PHP script:

<?  print_r($_SERVER); ?>

This configuration works as expected. When I change the form method to
POST

and submit the form, the client hangs, and I get the attached debug
from nginx, the connection only apparently closing because I press the
browser’s “stop” button, and an internal nginx 499 is generated.

Any ideas what’s happening?

Cheers,
Igor

On Fri, Aug 15, 2008 at 09:31:21AM +0100, Igor C. wrote:

Igor, this is great news, thank you. Will it be in the 0.6.x branch release?

Yes, it will be merged. The patch should be suitable for 0.6.x.

I’ve tried it on OSX/10.5.2 at home and it works. Fantastic. I’ll try it
on Linux at work tomorrow and see how it works with some of the projects
there.

This is great news; if it works out then I’ll be able to use the named
location config style in a lot of our projects.

Thank you, Igor!

----- Original Message -----
From: Igor S. [email protected]
To: [email protected]
Sent: Mon, 18 Aug 2008 19:16:08 +0100 (BST)
Subject: Re: static POST

On Mon, Aug 18, 2008 at 07:07:27PM +0100, Igor C. wrote:

location @phpapp {

and submit the form, the client hangs, and I get the attached debug
from nginx, the connection only apparently closing because I press the
browser’s “stop” button, and an internal nginx 499 is generated.

Any ideas what’s happening?

Try attached additional patch.

On Mon, Aug 18, 2008 at 07:07:27PM +0100, Igor C. wrote:

location @phpapp {

and submit the form, the client hangs, and I get the attached debug
from nginx, the connection only apparently closing because I press the
browser’s “stop” button, and an internal nginx 499 is generated.

Any ideas what’s happening?

Try attached additional patch.

Just FYI it seems to work the same on Linux and means the location-
only configs on loads of our existing projects are good to go without
if constructs.

Thanks!

On Tue, Aug 19, 2008 at 12:25:29PM +0100, Igor C. wrote:

Just FYI it seems to work the same on Linux and means the location-
only configs on loads of our existing projects are good to go without
if constructs.

Thanks!

OK, I will merged in next 0.6.33.

Igor,

Does this patch exist in the .0.7.* ? I think this is might be what has
been
making my form POST submits so horrendously slow.

Thanks

I was wondering why my POST data is not populated in PHP…

This is running nginx 0.7.19 right now. I am using the error_page and
POSTing data to it, and it’s not filling in the POST information.

server {
listen 80;
server_name foo.com;
index index.php;
root /home/mike/web/foo.com;
error_page 404 = /controller.php?uri=$request_uri;
location ~ .php {
fastcgi_pass 127.0.0.1:11000;
}
}

Is there something wrong with the configuration, or could the feature
have relapsed?

Yup I switched to this

    if (!-e $request_filename) {
            rewrite ^/(.*) /controller.php?uri=$request_uri last;
    }

and once again I get POST data.

So something is messed up with error_page and POST data in 0.7.19.
Behavior seems to be the same in 0.7.21 too.

On Wed, Sep 24, 2008 at 09:28:24PM +0000, David wrote:

Does this patch exist in the .0.7.* ? I think this is might be what has been
making my form POST submits so horrendously slow.

0.7.x has the following features:

Changes with nginx 0.7.12 26 Aug
2008

*) Bugfix: a request body was dropped while redirection via an
   "error_page" directive.

Changes with nginx 0.7.11 18 Aug
2008

*) Feature: now nginx returns the 405 status code for POST method
   requesting a static file only if the file exists.

They allow POSTs to nonexistent files and redirect them to a backend
using error_page.