Django DEBUG=False 导致所有请求出现 400 错误

Django DEBUG=False resulting in 400 error for all requests

我 运行 我的 Django 应用程序在 Docker 容器中,nginx 作为网络服务器,uWSGI 作为应用程序服务器。一切都部署在 AWS Elastic Beanstalk 上。当我设置 DEBUG=False 时,所有请求都会导致 Bad Request (400)ALLOWED_HOSTS='*'ALLOWED_HOSTS=['*'] 都试过了,还是报同样的错误。我通过检查日志验证了请求是发给 uWSGI 的。 uWSGI 日志有这个:

[pid: 33|app: 0|req: 4/4] 172.17.0.1 () {46 vars in 855 bytes} [Tue Aug  1 02:54:17 2017] GET / => generated 26 bytes in 26 msecs (HTTP/1.1 400) 1 headers in 53 bytes (1 switches on core 0)

我尝试了很多答案,但没有成功。我试过 ,但我仍然遇到同样的错误。还有其他可能导致这种情况的原因吗?

这个问题和this question, because, as I mentioned, setting ALLOWED_HOSTS to wildcard did not work for me. From the same question, I also tried this answer不一样,我还是报同样的错误

问题是我的 URL 有一个下划线,而 Django 不允许 URL 中的任何地方有下划线。我有 www._test_.example.comwww._test.example.comwww.a_test.example.com 也不起作用。 Underscores should be valid characters in URLs.