x-accel-redirect enables caching for POST requests

Maxim Dounin mdounin at mdounin.ru
Wed Dec 23 16:19:04 UTC 2015


Hello!

On Wed, Dec 23, 2015 at 07:10:43PM +0300, Руслан Закиров wrote:

> On Wed, Dec 23, 2015 at 6:49 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> 
> > X-Accel-Redirect changes a request from POST to GET.
> >
> 
> No, it doesn't. Getting request method POST on the backend and even form
> data is intact.

It does,
http://hg.nginx.org/nginx/file/tip/src/http/ngx_http_upstream.c#l2501:

            if (r->method != NGX_HTTP_HEAD) {
                r->method = NGX_HTTP_GET;
            }

Though it looks like it only does so for nginx itself, and this 
indeed looks like a bug.  The code should be similar to one in 
error_page handling:

        if (r->method != NGX_HTTP_HEAD) {
            r->method = NGX_HTTP_GET;
            r->method_name = ngx_http_core_get_method;
        }

If you want to get request and request method intact, use 
X-Accel-Redirect to a named location instead.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list