我已经在开发中运行一个Nginx的X-Accel代理服务器,具有以下configuration:
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/; } }
哪个工作正常,直到我意识到我的Nginx是1.4.6,并且非常过时,因为我接近生产,并试图确保我有最新的更新等。
现在使用1.10.1,这个不再有效,所有的POST请求都在Nginx的前台收到,但是当它们最终被代理到http://127.0.0.1:8081/时,它们被作为GET方法接收。
编辑:此外,确认gate_proxy( http://127.0.0.1:8889 )更新后仍然收到POST方法。
通过https://stackoverflow.com/a/41282238/698289解决
在我自己的configuration中, location /x-accel-apache/ section现在看起来像:
# 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; }
在gate_proxy中,我设置了以下内容:
set_header('X-Accel-Redirect', '@webapp') set_header('X-Accel-Redirect-Location', request_path)
确认与当前最新的稳定(1.10.3)和主线(1.11.9)