代码之家  ›  专栏  ›  技术社区  ›  user2233706

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

  •  2
  • user2233706  · 技术社区  · 7 年前

    我正在Docker容器中运行我的Django应用程序,其中nginx作为Web服务器,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 answer ,但我仍然得到相同的错误。还有什么可能导致这种情况吗?

    这个问题不同于 this question ,因为,正如我提到的,设置 ALLOWED_HOSTS this answer ,我仍然得到相同的错误。

    1 回复  |  直到 7 年前
        1
  •  1
  •   user2233706    7 年前

    www._test_.example.com . www._test.example.com www.a_test.example.com Underscores should be valid characters in URLs .