Malformed nginx 307 redirect response?

BrandonAGr asked:

I have an Nginx configuration that 307 redirects from http to https. There are existing client applications that connect to http and send data via POST requests. The clients are .Net services using HttpWebRequest. Just using 301 redirect results in the POST data getting dropped from the request.

I have the 307 redirect working in my local test environment, but when deployed to the production server the redirect message is getting corrupted, and the clients are throwing an exception.

This is the working response I get in my test environment:
Working 307 redirect

And this is what I get from the production environment
enter image description here

You can see how the packet looks different, what could be causing the different responses? The older version of nginx?

My answer:

Versions of nginx prior to 1.1.16 did not properly support returning 307 responses.

The change log reads, in relevant part:

Changes with nginx 1.1.16                                        29 Feb 2012

    *) Feature: the "return" and "error_page" directives can now be used to
       return 307 redirections.

I recommend you bring your production (and your development!) server up to date if you need this functionality. nginx 1.0.5 is very old at this point.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.