title: nginx conditional proxy pass based on request body content
body: <p>I am trying to configure nginx to proxy pass the request to another server, only if the $request_body variable matches on a specific regular expression.But it is not working for me.</p>
  
  <pre><code> server{
          listen 80 default;
          server_name www.applozic.com;
  
          location / {
                   proxy_set_header X-Real-IP $remote_addr;
                   proxy_set_header X-Forwarded-For $remote_addr;
                   proxy_set_header Host $http_host;
  
                  if ($request_body ~* (.*)appId(.*)) {
                     proxy_pass http://apps.applozic.com;
                  }
          }
  </code></pre>
  
  <p>}</p>
  
  <p>request body is::</p>
  
  <pre><code>              {
                 "applicationId": "appId",
                 "authenticationTypeId": 1,
                 "enableEncryption": false,
                 "notificationMode": 0,
                 "deviceType": 4,
                }
  </code></pre>