如何在Nginx服务器上允许PUT文件请求?
我在HTTP服务器上使用的应用程序需要 PUT
一个文件。我使用Nginx作为服务器,但得到 405 Not Allowed
错误。以下是使用cURL进行测试的示例:
I am using an application which needs to PUT
a file on a HTTP server. I am using Nginx as the server but getting a 405 Not Allowed
error back. Here is an example of a test with cURL:
curl -X PUT \
-H 'Content-Type: application/x-mpegurl' \
-d /Volumes/Extra/playlist.m3u8 http://xyz.com
我从Nginx回来的东西:
And what I get back 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>
我需要做什么才能允许 PUT
?
What do I need to do to allow the PUT
?
任何线索都很棒!
添加HTTP和WebDAV方法,如PUT,DELETE,MKCOL,COPY和MOVE,你需要用 HttpDavModule
编译nginx( ./ configure --with-http_dav_module
)。首先检查 nginx -V
,也许你已经拥有 HttpDavModule
(我从Debian存储库安装了nginx,我已经有了模块。
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).
然后改变你的nginx-config:
Then change your nginx-config like that:
location / {
root /var/www;
dav_methods PUT;
}
您可以获得有关 HttpDavModule的nginx docs条目。