What is the configuration needed in Nginx to achieve the following behavior:
Whenever a request is received, it should be forwarded to application A; if application A returns { "allowed" :true} in response, the same request should be forwarded to application B and the response from application B should be returned to the client. However, if application A returns a { "allowed" : false} in response, the server should return a response with a status code of 401.
Something like this:
server {
listen 80;
location / {
# forword request to App-A;
proxy_pass https://app-A.dev/;
# Read the response
if response['allowed'] == true;
# forword it to application B
proxy_pass https://app-B.dev/;
else:
return '401';
}
}