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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!
I had a similar problem running a simple REST-like API using Nginx and PHP. <br> <br>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). <br> <br>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. <br> <br>I now use a rewrite to send requests to “/” to “/index.php” like this: <br> <br> location = / { <br> rewrite / /index.php last; <br> } <br> <br> <br>(I’m not a ngnix pro, so take all of the above with a grain of salt :)
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
Have you restarted nginx after editing the config file?
Check out <a href=“https://www.digitalocean.com/community/articles/how-to-host-multiple-node-js-applications-on-a-single-vps-with-nginx-forever-and-crontab”>How To Host Multiple Node.js Applications On a Single VPS with nginx, forever, and crontab</a>