0

I've been running an Nginx X-Accel Proxy in development with the following config:

upstream gate_proxy {
    server 127.0.0.1:8889;
}

server {
    listen      80 default_server;
    server_name default;
    charset     utf-8;
    client_max_body_size 75M;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Send all traffic to gate first
    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://gate_proxy;
    }

    # Proxy to Apache after X-Accel
    location /x-accel-apache/ {
        internal;
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme $scheme;

        # Make sure the trailing slash is maintained here, as this affects the URI relayed.
        proxy_pass http://127.0.0.1:8081/;
    }
}

Which was working fine, until I realised my Nginx was 1.4.6 and very out of date as I near production and seek to make sure I have the latest updates etc.

Now with 1.10.1 this no longer works and all POST requests are received as such in Nginx on the frontline, but when they are eventually proxied to http://127.0.0.1:8081/ they are received as GET method.

EDIT: Also, confirmed that gate_proxy (http://127.0.0.1:8889) also receives POST method still after the update.

DanH
  • 827
  • 2
  • 9
  • 26

1 Answers1

2

Solved by https://stackoverflow.com/a/41282238/698289

In the context of my own config, the location /x-accel-apache/ section now looks like:

# Proxy to Apache after X-Accel
location @webapp {        
    internal;
    proxy_pass_header Server;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Scheme $scheme;

    set                     $stored_redirect_location $upstream_http_x_accel_redirect_location;
    proxy_pass              http://127.0.0.1:8081$stored_redirect_location;
}

And in the gate_proxy I set the following:

set_header('X-Accel-Redirect', '@webapp') set_header('X-Accel-Redirect-Location', request_path)

Confirmed to be working with current latest stable (1.10.3) and mainline (1.11.9)

DanH
  • 827
  • 2
  • 9
  • 26