title: How to configure nginx for a RESTful API?
body: <p>I have a RESTful web service which exposes an interface such as :</p>
  
  <ul>
  <li><code>GET /api/v1/films/:id/thumb</code></li>
  <li><code>PUT /api/v1/films/:id/thumb</code></li>
  <li><code>...</code></li>
  </ul>
  
  <p>The Web Server is composed of a nodejs cluster behind a nginx reverse proxy.</p>
  
  <p>I am now trying to configure nginx proxy and client buffers. To this end I set the directives </p>
  
  <pre><code>    location ~ /api/v1/films/(.*)/thumb {
          proxy_buffers 6 500k;
          proxy_busy_buffers_size 1m;
          client_max_body_size 3m;
          client_body_buffer_size 3m;
          proxy_pass http://backend;
      }
  </code></pre>
  
  <p>This configuration does the job but is unsatisfying since it configures <code>proxy_buffers 3m</code> for the <code>PUT</code> request which is unnecessary and a waste of resources and a <code>client_max_body_size 3m</code> for a <code>GET</code>.</p>
  
  <p>And so I am looking for a way of configuring my routes based on http methods in addition to URIs.</p>
  
  <p>Thanks to everyone willing to share a bit of experience.</p>