<div dir="ltr"><div><div>Hi All,<br><br></div>I am trying to collect the POST request body using $request_body but I am unable to collect it in config file:<br><br># curl -X POST -d "param1=value1&param2=value2" '<a href="http://localhost:8031/test1/test2/">http://localhost:8031/test1/test2/</a>' --header "Content-Type:application/json"<br>
<br> location /test1  {<br>...........................<br>               if ( $request_body ~ (.*?)(=)(.*?)(&)(.*?)(=)(.*) )<br>                {<br>                  echo $1; echo $2; echo $3;<br>                }<br>
}<br><br></div>But when I tried to use the nginx-echo module, I was able to print it but I couldn't use it in if().<br><br> location /test1  {<br>
...........................<br>echo_read_request_body;<br>echo $request_body;<br>set $foo $echo_request_body;<br>echo $foo;<br>               if ( $foo ~ (.*?)(=)(.*?)(&)(.*?)(=)(.*) )<br>
                {<br>
                  echo $1; echo $2; echo $3;<br>
                }<br>}<br><div><br>#curl -X POST -d "param1=value1&param2=value2" '<a href="http://localhost:8031/test1/test2/">http://localhost:8031/test1/test2/</a>' --header "Content-Type:application/json"<br>
param1=value1&param2=value2<br><br></div><div>foo value is not getting echoed out. So the condition is not entering if().<br><br></div><div>Actually I intention is to load balance according to data in POST request.<br>
</div><div><br></div><div>Thanks<br></div><div>Eswar<br></div></div>