Nginx returns 405 (method not allowed) for PUT or DELETE

I use nginx to serve static pages, but to pass API requests to a Tornado application that I would like to handle with GET, POST, PUT and DELETE requests.

GET and POST requests are fine, but PUT and DELETE requests are rejected with "405: method not allowed"

This question asks the same thing: How to allow a PUT file request on a Nginx server? but the answer does not solve my problem, which makes me think it is related to my use of proxy_pass in my setup.

Here is my nginx server configurator:

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 /<<static url>>/ {
                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 /<<API url>>/ {
                dav_methods PUT DELETE;
                dav_access all:r;
                proxy_pass http://TornadoAPI/api/;
        }
}

HttpDavModule ( , HttpDav - ) . , nginx -V.

nginx access.log:

<<IP address>> - - [06/Mar/2014:16:29:57 +0000] "PUT /<<API url>>/<<resource>> HTTP/1.1" 405 87 "<<ngix server root url>>" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36"

- , , PUT DELETE?

+4
1

dav_methods PUT DELETE MKCOL COPY MOVE;

nginx http://nginx.org/en/docs/http/ngx_http_dav_module.html

0

Source: https://habr.com/ru/post/1530461/


All Articles