How do I allow a PUT file request on Nginx server?

Another reason for 405 Not Allowed is that you don't have permission to write files on the destination you're PUTing. If you have HttpDavModule and still getting this error, make sure you've given nginx write permissions where you're PUTing the files.


To add HTTP and WebDAV methods like PUT, DELETE, MKCOL, COPY and MOVE you need to compile nginx with HttpDavModule (./configure --with-http_dav_module). Check nginx -V first, maybe you already have the HttpDavModule (I installed nginx from the Debian repository and I already have the module).

Then change your nginx-config like that:

location / {
    root     /var/www;
    dav_methods  PUT;
}

You can get more info on the nginx docs entry for the HttpDavModule.

Tags:

Nginx

Http

Put