gpt4 book ai didi

django - 错误请求 400 : nginx/gunicorn

转载 作者:行者123 更新时间:2023-11-28 19:35:46 28 4
gpt4 key购买 nike

我已遵循本教程:http://blog.wercker.com/2013/11/25/django-16-part3.html我现在只是想让它在本地与 Vagrant 一起工作。我没有尝试使用 Wercker。

安装完所有内容后,我尝试访问该网站,但每次都收到Bad Request (400) 错误。我不知道这是由于 nginx 还是 gunicorn 的问题。

它们都有一个日志条目,所以至少我知道请求一直通过 gunicorn 并且没有在 nginx 级别停止。

问题出在哪里? unicorn ? nginx?

这里是gunicorn和nginx的日志。

我看到 favicon 不见了,但这应该不会阻止页面显示吧?

unicorn :

 >>> cat /var/local/sites/hellocities/run/gunicorn.error.log
10.0.0.1 - - [28/Jan/2014:07:05:16] "GET / HTTP/1.0" 400 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:09:43] "GET / HTTP/1.0" 400 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"

Nginx:

>>> cat /var/log/nginx/hellocities-access.log
10.0.0.1 - - [28/Jan/2014:07:05:16 +0000] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:05:20 +0000] "GET /favicon.ico HTTP/1.1" 404 200 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:09:43 +0000] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:09:44 +0000] "GET /favicon.ico HTTP/1.1" 404 200 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"

>>> cat /var/log/nginx/hellocities-error.log
2014/01/28 07:05:20 [error] 13886#0: *1 open() "/var/local/sites/hellocities/static/favicon.ico" failed (2: No such file or directory), client: 10.0.0.1, server: _, request: "GET /favicon.ico HTTP/1.1", host: "10.0.0.200"
2014/01/28 07:09:44 [error] 13886#0: *3 open() "/var/local/sites/hellocities/static/favicon.ico" failed (2: No such file or directory), client: 10.0.0.1, server: _, request: "GET /favicon.ico HTTP/1.1", host: "10.0.0.200"

最佳答案

我遇到了同样的问题并在设置中添加 ALLOWED_HOSTS = ("yourdomain.com",) 修复了它。

更新:几乎没有其他可能性:

  1. Nginx(或您使用的任何网络服务器)不会将 $host 变量传递给应用
  2. 宿主包含下划线

查看详情:https://blog.anvileight.com/posts/how-to-fix-bad-request-400-in-django/

关于django - 错误请求 400 : nginx/gunicorn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21399288/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com