title: nginx conditional proxy pass
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. </p>
  
  <p>My problem now is, that I don't how to configure this behaviour exactly. </p>
  
  <p>I am currently down to this one:</p>
  
  <pre><code>server {
      listen 80 default;
      server_name test.local;
  
      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 ~* ^(.*)\.test) {
                      proxy_pass http://www.google.de;
              }
  
              root /srv/http;
      }
  
  }
  </code></pre>
  
  <p>but the problem here is, that root has always the upperhand. 
  the proxy won't be passed either way. </p>
  
  <p>any idea on how I could accomplish this?</p>
  
  <p>thanks in advance</p>