Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

How to redirect requests based on request_body regex match ?

$
0
0
Hello All,

I was trying to use nginx in a proxy_pass mode, and redirect requests to a set of servers based on the $request_body contents. I tried the following simplified sample configuration but it does not seem to work.

server {

# Some config settings...

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;

if ($request_body ~* 'my_param=.+%23.+' )
{
proxy_pass http://server_group_b;
break;
}

proxy_pass http://server_group_a;
}
}

Could someone please explain why this would not work and a better way to do it ?

Thanks.

}

Viewing all articles
Browse latest Browse all 4759

Trending Articles