如何在Nginx服务器上允许PUT文件请求? [英] How do I allow a PUT file request on Nginx server?

查看:5596
本文介绍了如何在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条目

这篇关于如何在Nginx服务器上允许PUT文件请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆