如何在 Nginx 服务器上允许 PUT 文件请求? [英] How do I allow a PUT file request on Nginx server?
问题描述
我使用的应用程序需要在 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
?
任何线索都会很棒!
推荐答案
要添加 PUT、DELETE、MKCOL、COPY 和 MOVE 等 HTTP 和 WebDAV 方法,您需要使用 HttpDavModule
(./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 文档条目 中获取更多信息.
You can get more info on the nginx docs entry for the HttpDavModule.
这篇关于如何在 Nginx 服务器上允许 PUT 文件请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!