今天碰到一個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...
原創內容如轉載請註明:來自
阿權的書房