title: Rate Limiting on NGINX using POST args
body: <p>I need to apply rate limiting in nginx based on 2 conditions:</p>
  
  <ol>
  <li>the method is POST </li>
  <li>the post args includes "_api" key</li>
  </ol>
  
  <p><strong>1. This is unable to detect the _api key in the Post Request:</strong></p>
  
  <pre><code>limit_req_zone "$arg__api" zone=api_zone:10m rate=30r/m;
  limit_req zone=api_zone burst=10 nodelay;
  </code></pre>
  
  <p><strong>2. This can detect the POST method:</strong></p>
  
  <pre><code>map $request_method $limit {
    default "";
    POST $binary_remote_addr;
  }
  
  limit_req_zone $limit zone=my_zone:10m rate=20r/m;
  limit_req zone=my_zone burst=10 nodelay;
  </code></pre>
  
  <p>So how can I both detect that it is a POST and that the post contains the _api key ?</p>
  
  <h1>UPDATE 1</h1>
  
  <p>I just tried detecting the _api key in post with this but it does not work either:</p>
  
  <pre><code>map $request_body $api { 
    "_api" $binary_remote_addr;
    default "";
  } 
  limit_req_zone $api zone=api_api:10m rate=30r/m;
  limit_req zone=api_api burst=10 nodelay;
  </code></pre>