title: nginx returns 405 (Method Not Allowed) for PUT or DELETE
body: <p>I am using nginx to serve static pages but to pass requests to an API on to a Tornado application, which I would like to handle GET, POST, PUT and DELETE requests.</p>
  
  <p>GET and POST requests are fine, but PUT and DELETE requests are rejected with "405: Method Not Allowed"</p>
  
  <p>This question asks much the same: <a href="https://stackoverflow.com/questions/16912270/how-do-i-allow-a-put-file-request-on-nginx-server">How do I allow a PUT file request on Nginx server?</a> but the answer doesn't solve my issue, which makes me think it's related to my use of proxy_pass in my setup.</p>
  
  <p>Here's my nginx server config:</p>
  
  <pre><code>upstream TornadoAPI {
          server 127.0.0.1:8000;
  }
  
  server {
          listen 80;
          listen [::]:80 default_server ipv6only=on;
  
          root /usr/share/nginx/html;
          index index.html index.htm;
  
          # Make site accessible from http://localhost/
          server_name localhost;
  
          location /&lt;&lt;static url&gt;&gt;/ {
                  root /var/www;
                  index index.html;
                  # First attempt to serve request as file, then
                  # as directory, then fall back to displaying a 404.
                  try_files $uri $uri/ /index.html;
                  # Uncomment to enable naxsi on this location
                  # include /etc/nginx/naxsi.rules
          }
  
          location /&lt;&lt;API url&gt;&gt;/ {
                  dav_methods PUT DELETE;
                  dav_access all:r;
                  proxy_pass http://TornadoAPI/api/;
          }
  }
  </code></pre>
  
  <p>I have attempted to use the HttpDavModule directives (though I don't think my application qualifies as HttpDav - I have no intention on letting users write files) without luck. I have confirmed the module's presence by inspecting nginx -V.</p>
  
  <p>Here's an example output from the nginx access.log:</p>
  
  <pre><code>&lt;&lt;IP address&gt;&gt; - - [06/Mar/2014:16:29:57 +0000] "PUT /&lt;&lt;API url&gt;&gt;/&lt;&lt;resource&gt;&gt; HTTP/1.1" 405 87 "&lt;&lt;ngix server root url&gt;&gt;" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36"
  </code></pre>
  
  <p>Can someone suggest what else I can do to accept the PUT and DELETE methods?</p>