Welcome! Log In Create A New Profile

Advanced

Re: x-accel-redirect enables caching for POST requests

Maxim Dounin
December 24, 2015 05:24PM
Hello!

On Thu, Dec 24, 2015 at 12:16:43AM +0300, Руслан Закиров wrote:

> On Wed, Dec 23, 2015 at 7:19 PM, Maxim Dounin <mdounin@mdounin.ru> wrote:
>
> > On Wed, Dec 23, 2015 at 07:10:43PM +0300, Руслан Закиров wrote:
> >
> > > On Wed, Dec 23, 2015 at 6:49 PM, Maxim Dounin <mdounin@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
> >
>
> Would you create an issue for this in tracker or do I need to so it doesn't
> disappear in archives?

No real need to open tickets. I've submitted a patch for an
internal review here. Just in case, patch below.


# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1450981046 -10800
# Thu Dec 24 21:17:26 2015 +0300
# Node ID 10e233c763566b8466f6e302511094866a14e77a
# Parent 78b4e10b4367b31367aad3c83c9c3acdd42397c4
Upstream: fixed changing method on X-Accel-Redirect.

Previously, only r->method was changed, resulting in handling of a request
as GET within nginx itself, but not in requests to proxied servers.

See http://mailman.nginx.org/pipermail/nginx/2015-December/049518.html.

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2499,6 +2499,7 @@ ngx_http_upstream_process_headers(ngx_ht

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

ngx_http_internal_redirect(r, &uri, &args);


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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

x-accel-redirect enables caching for POST requests

Руслан Закиров December 23, 2015 07:56AM

Re: x-accel-redirect enables caching for POST requests

Maxim Dounin December 23, 2015 10:50AM

Re: x-accel-redirect enables caching for POST requests

Руслан Закиров December 23, 2015 11:12AM

Re: x-accel-redirect enables caching for POST requests

Руслан Закиров December 23, 2015 11:16AM

Re: x-accel-redirect enables caching for POST requests

Maxim Dounin December 23, 2015 11:20AM

Re: x-accel-redirect enables caching for POST requests

Руслан Закиров December 23, 2015 04:18PM

Re: x-accel-redirect enables caching for POST requests

Maxim Dounin December 24, 2015 05:24PM

Re: x-accel-redirect enables caching for POST requests

gglater62 February 09, 2016 01:06PM

Re: x-accel-redirect enables caching for POST requests

Maxim Dounin February 09, 2016 01:16PM

Re: x-accel-redirect enables caching for POST requests

gglater62 February 09, 2016 03:53PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 235
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready