# Reg. POST data body

**URL:** <https://www.ruby-forum.com/t/reg-post-data-body/228637>\
**Category:** NGINX\
**Created:** [May 1, 2013, 11:34am UTC](https://www.ruby-forum.com/t/reg-post-data-body/228637 "2013-05-01T11:34:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eswar\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e47774/32.png) [@eswar\_r](https://www.ruby-forum.com/u/eswar_r)\
**Post date:** [May 1, 2013, 11:34am UTC](https://www.ruby-forum.com/t/reg-post-data-body/228637/1 "2013-05-01T11:34:37Z")

</div>

Hi All,

I am trying to collect the POST request body using $request\_body but I  
am  
unable to collect it in config file:

# curl -X POST -d “param1=value1&param2=value2” ’

[http://localhost:8031/test1/test2/](http://localhost:8031/test1/test2/)’ --header  
“Content-Type:application/json”

location /test1 {  
…  
if ( $request\_body ~ (._?)(=)(._?)(&)(._?)(=)(._) )  
{  
echo $1; echo $2; echo $3;  
}  
}

But when I tried to use the nginx-echo module, I was able to print it  
but I  
couldn’t use it in if().

location /test1 {  
…  
echo\_read\_request\_body;  
echo $request\_body;  
set $foo $echo\_request\_body;  
echo $foo;  
if ( $foo ~ (._?)(=)(._?)(&)(._?)(=)(._) )  
{  
echo $1; echo $2; echo $3;  
}  
}

#curl -X POST -d “param1=value1&param2=value2” ’  
[http://localhost:8031/test1/test2/](http://localhost:8031/test1/test2/)’ --header  
“Content-Type:application/json”  
param1=value1&param2=value2

foo value is not getting echoed out. So the condition is not entering  
if().

Actually I intention is to load balance according to data in POST  
request.

Thanks  
Eswar
