Welcome! Log In Create A New Profile

Advanced

Re: $request_method variable shows wrong value

Maxim Dounin
January 18, 2017 07:34AM
Hello!

On Tue, Jan 17, 2017 at 11:48:51AM -0500, mastercan wrote:

> I have a setup where I'm using an Accel-Redirect header in php like this:
> header("X-Accel-Redirect: /testxxx.php?".$_SERVER['QUERY_STRING']);
>
> Furthermore I'm using HTTP/2.0 and SSL, running on nginx 1.11.8.
>
> The problem is: When doing a POST request on my upload.php (which then does
> an x-accel-redirect to testxxx.php) the $request_method has the value
> "GET".

That's correct. After a redirection via X-Accel-Redirect to an
URI, the request method is changed to GET, much like it happens
after error_page redirections (see http://nginx.org/r/error_page).
If you want to preserve the original request method, use
a redirection to a named location.

> I have a section in my nginx php config where I use "add_header" to output
> the value of $request_method. So that's how I know this value is set to
> "GET".
>
> Some weeks ago this was working correct. All I changed since then was
> switching to HTTPS.

This might work previously with old nginx versions, as previously
there was a bug which preserved original request method string
representation after X-Accel-Redirect. The bug was fixed in nginx
1.9.10:

*) Bugfix: proxying used the HTTP method of the original request after
an "X-Accel-Redirect" redirection.

This also affects the $request_method variable value you use.

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

$request_method variable shows wrong value

mastercan January 17, 2017 11:48AM

Re: $request_method variable shows wrong value

Maxim Dounin January 18, 2017 07:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 289
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