Proxying of POST requests based on $args not working

Hi,

The proxying of GET requests on $args i.e. feedid=293634 goes to server2
properly.

But proxying of POST requests on $args i.e. feedid=293634 always goes to
server1 instead of server2.

Following is configuration…

  1. /etc/nginx/nginx.conf contains

user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/proxy.conf;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
log_format main '$remote_addr - $remote_user [$time_local] “$request” ’
'$status $body_bytes_sent “$http_referer” ’
‘"$http_user_agent" “$http_x_forwarded_for”’;
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 70;
include /tmp/routing.conf ;
}

  1. /etc/nginx/proxy.conf contains

proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
client_body_buffer_size 100m;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffers 32 4k;
proxy_next_upstream error timeout http_500 http_502 http_503 http_504
http_404 invalid_header;
log_format postdata $request_body;

  1. /tmp/routing.conf contains

upstream server1 {
server 192.168.20.202:8090;
}
upstream server2 {
server 127.0.0.1:8080;
}

server {
listen 80;
server_name mysubdomain.domain.co.in;

location / {
proxy_pass http://server1;

if ( $args ~ ‘feedid=293634’ ) {
proxy_pass http://server2;
}
if ( $request_method = POST ) {
set $test P;
}
if ( $args ~ ‘feedid=293634’ ) {
set $test “${test}C”;
}
if ( $test = PC) {
proxy_pass http://server2;
}
}
}

Any suggestions…

Thanks,
M. G.

Hello!

On Thu, May 08, 2014 at 11:49:55PM -0700, M. G. wrote:

Hi,

The proxying of GET requests on $args i.e. feedid=293634 goes to server2
properly.

But proxying of POST requests on $args i.e. feedid=293634 always goes to server1
instead of server2.

The $args variable is “arguments in the request line”, see
http://nginx.org/r/$args. It is not expected to contain any data
from POST request body.


Maxim D.
http://nginx.org/

Hi,

On Friday, 9 May 2014 12:36 PM, Maxim D. [email protected]
wrote:

The $args variable is “arguments in the request line”, see
http://nginx.org/r/$args. It is not expected to contain any data from
POST request body.

Firstly thank you for your quick response.

We need to proxy a specific request eg. when feedid=293634 and the
request method is POST.

How can we achieve the same, if possible requesting an sample
configuration for our reference.

Thanks,

M. G.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs