I have an XML request body where I want to extract a value like:
<?xml version="1.0" ?><Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><Body><myvariable>123</myvariable></Body></Envelope>
I want to extract the value in the tag, assign it to the nginx variable and then if the value is set, use it for rate limiting.
So far as far as my research goes, the only way to extract a regex based group from the $request_body variable is through the map like:
map $request_body $student_id {
"~.*<myvariable>(.*)</myvariable>.*" $s;
default 0;
}
My understanding is the $s variable will hold the capture group and then I can use it like:
if ($s = 123)
{
rate_limit;
}
But the above is not working. Have someone done something like the above? Any pointers will be really appreciated.