Ruby Forum NGINX > static POST

Posted by Igor Sysoev (Guest)
on 14.08.2008 14:22
Attachment: patch.static_post (1,1 KB)
(Received via mailing list)
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.
Posted by Delta Yeh (Guest)
on 15.08.2008 09:15
(Received via mailing list)
What does this feature use for?  Any scenarios?

2008/8/14 Igor Sysoev <is@rambler-co.ru>
Posted by Igor Sysoev (Guest)
on 15.08.2008 09:16
(Received via mailing list)
On Fri, Aug 15, 2008 at 03:05:42PM +0800, Delta Yeh wrote:

> What does this feature use for?  Any scenarios?

This configuration is replacement of ugly hack:

   location / {

       if (-e $request_filename) {
           break;
       }

       proxy_pass  ...
   }
Posted by Igor Clark (Guest)
on 15.08.2008 10:41
(Received via mailing list)
Igor, this is great news, thank you. Will it be in the 0.6.x branch 
release?

----- Original Message -----
From: Igor Sysoev <is@rambler-co.ru>
To: nginx@sysoev.ru
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 Yeh wrote:

> What does this feature use for?  Any scenarios?

This configuration is replacement of ugly hack:

   location / {

       if (-e $request_filename) {
           break;
       }

       proxy_pass  ...
   }
Posted by Igor Sysoev (Guest)
on 15.08.2008 10:59
(Received via mailing list)
On Fri, Aug 15, 2008 at 09:31:21AM +0100, Igor Clark 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.
Posted by Igor Clark (Guest)
on 15.08.2008 14:46
(Received via mailing list)
Superb. Thanks Igor.

----- Original Message -----
From: Igor Sysoev <is@rambler-co.ru>
To: nginx@sysoev.ru
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 Clark 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.
Posted by Igor Clark (Guest)
on 18.08.2008 20:19
Attachment: nginx-post-debug.txt (12 KB)
(Received via mailing list)
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:

  <form method="GET" action="/blah"> <input type="text" name="value">
<input type="submit"> </form>

PHP script:

  <pre><?  print_r($_SERVER); ?></pre>

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

  <form method="POST" action="/blah"> <input type="text" name="value">
<input type="submit"> </form>

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
Posted by Igor Sysoev (Guest)
on 18.08.2008 20:25
Attachment: patch.static.POST1 (866 Bytes)
(Received via mailing list)
On Mon, Aug 18, 2008 at 07:07:27PM +0100, Igor Clark wrote:

>   location @phpapp {
>   <form method="GET" action="/blah"> <input type="text" name="value">  
> <input type="submit"> </form>
> 
> 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.
Posted by Igor Clark (Guest)
on 18.08.2008 23:23
(Received via mailing list)
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 Sysoev <is@rambler-co.ru>
To: nginx@sysoev.ru
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 Clark wrote:

>   location @phpapp {
>   <form method="GET" action="/blah"> <input type="text" name="value">  
> <input type="submit"> </form>
> 
> 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.
Posted by Igor Clark (Guest)
on 19.08.2008 13:31
(Received via mailing list)
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!
Posted by Igor Sysoev (Guest)
on 19.08.2008 13:37
(Received via mailing list)
On Tue, Aug 19, 2008 at 12:25:29PM +0100, Igor Clark 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.
Posted by David (Guest)
on 24.09.2008 23:36
(Received via mailing list)
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
Posted by Igor Sysoev (Guest)
on 26.09.2008 12:08
(Received via mailing list)
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.
Posted by mike (Guest)
on 19.11.2008 09:09
(Received via mailing list)
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?
Posted by mike (Guest)
on 19.11.2008 09:13
(Received via mailing list)
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.