How to allow PUT file request on Nginx server?

I am using an application that needs a PUT file on an HTTP server. I am using Nginx as a server, but getting a 405 Not Allowed error. Here is an example test with cURL:

 curl -X PUT \ -H 'Content-Type: application/x-mpegurl' \ -d /Volumes/Extra/playlist.m3u8 http://xyz.com 

And that I will return from Nginx:

 <html> <head><title>405 Not Allowed</title></head> <body bgcolor="white"> <center><h1>405 Not Allowed</h1></center> <hr><center>nginx/1.1.19</center> </body> </html> 

What do I need to do to enable PUT ?

Any tips would be awesome!

+6
source share
2 answers

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

Then modify your nginx-config as follows:

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

You can get more information about the nginx docs entry for the HttpDavModule .

+16
source

Another reason for 405 Not Allowed is that you do not have permission to write files to the PUT ing destination. If you have an HttpDavModule and you still get this error, make sure you grant nginx write permissions where you PUT upload files.

+1
source

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


All Articles