Welcome! Log In Create A New Profile

Advanced

How to redirect requests based on request_body regex match ?

Posted by vikasap 
How to redirect requests based on request_body regex match ?
November 17, 2014 03:50PM
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.

}
Re: How to redirect requests based on request_body regex match ?
November 18, 2014 04:56PM
I think I will have to use something like "echo_read_request_body" from the "HttpEchoModule" to get the post body only when really required and expect the $request_body to be filled up.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 209
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready