【发布时间】:2016-01-19 14:34:32
【问题描述】:
我使用 nginx+gunicorn+supervisor 开发了 Django Web 应用程序。它运行良好。但是当我尝试在 django admin 中添加带有图片的新帖子时,我收到 405 错误。在开发人员服务器上工作正常。 我的 nginx 配置如下:
upstream app_server {
server unix:/tmp/PMC.sock fail_timeout=0;
}
server {
listen 80;
server_name site.ru;
access_log /home/venv/PMC/logs/nginx-access.log main;
error_log /home/venv/PMC/logs/nginx-error.log debug;
location /static/ {
alias /home/venv/PMC/static/;
access_log off;
}
location /media/ {
alias /home/venv/PMC/media/;
access_log off;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
}
【问题讨论】:
-
不确定这是 nginx 问题。你的 nginx 日志中是否有相应的错误?如果是这样的话。如果没有,请从您的应用程序中发布相关代码,尤其是将视图和 URL 路由器发布到您的
POST请求所访问的 URL 的视图中。