您的位置:首页 > 运维架构 > Nginx

NGINX: 405 Not Allowed

2013-11-06 10:53 666 查看
今天碰到一个dz的批量上传文件不成功的问题。

追踪发现,是把静态文件都优化了新地址导致的,用图片服务器存放了swf文件

swf文件上传文件时,就变成向静态文件做post,nginx就会返回405错误

修正域名即可解决。

另外,发现一个好玩的:

NGINX不允许向静态文件提交POST方式的请求,否则报405错误。测试方法为,使用curl向服务器上的静态文件提交POST请求:

curl -d 1=1 http://localhost/version.txt
得到以下结果:

<html>

<head><title>405 Not Allowed</title></head>

<body bgcolor="white">

<center><h1>405 Not Allowed</h1></center>

<hr><center>nginx/1.0.11</center>

</body>

</html>

网上传抄的添加以下配置的解决办法不可用:

error_page 405 =200 @405;

location @405

{

root /srv/http;

}

一种不完美但可用的方法为:

upstream static_backend {

server localhost:80;

}

server {

listen 80;

# ...

error_page 405 =200 @405;

location @405 {

root /srv/http;

proxy_method GET;

proxy_pass http://static_backend;
}

}

即转换静态文件接收的POST请求到GET方式。

http://0x3f.org/blog/nginx...

原创内容如转载请注明:来自
阿权的书房
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: