nginx, 405 Not allowed against PUT method

October 9, 2013 19.7k views
Hi there! Please help, I'm trying to make my nginx reverse proxy work with my node.js restful api, but always getting 405 Not allowed error on PUT request. I've already tried to include "dav_methods PUT DELETE;" line in my config but it seems not working. Server runs with --with-http_dav_module flag in Ubuntu 12.04. here is my config: server { listen 80; server_name howconscious.ru; location /site/ { dav_methods PUT DELETE; proxy_pass http://localhost:1337/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } Thanks in advance!
4 Answers
Have you restarted nginx after editing the config file?
thank for the answers, I restart the server every time I edit the config, and my config is taken exactly from that local tutorial. I've googled a lot of stuff on this topic and this problem seems unsolvable, thus nginx reverse proxy doesn't allow to use at least PUT and DELETE methods
I had a similar problem running a simple REST-like API using Nginx and PHP.

First of all, I think using the the http_dav_module and its dav_methods is just wrong, so remove that (we're not doing WebDav).

My problem was that I was relying on index (ngx_http_index_module) to take my "/" requests to "/index.php" , but the ngx_http_index_module does not like PUT and DELETE. So if you have an "index" directive, try to remove or replace it and see if that helps.

I now use a rewrite to send requests to "/" to "/index.php" like this:

location = / {
rewrite / /index.php last;
}


(I'm not a ngnix pro, so take all of the above with a grain of salt :)
Have another answer? Share your knowledge.