【问题标题】:Bad request 400 when debug = Falsedebug = False 时出现错误请求 400
【发布时间】:2016-03-11 20:39:45
【问题描述】:

当我设置 debug = false 时,我遇到了“错误请求 400”(生产服务器)的问题。我使用 cookiecutter 和 Django 1.8。 我设置了ALLOWED_HOSTS = ['*'] - 没有任何结果。

在日志中我有一条消息:

Invalid HTTP_HOST header: 'myaddress.here'. You may need to add 'myaddress.here' to ALLOWED_HOSTS.

我尝试了放置在文档 django 中的代码,也没有成功:

'handlers': {
    'null': {
        'class': 'logging.NullHandler',
    },
},
'loggers': {
    'django.security.DisallowedHost': {
        'handlers': ['null'],
        'propagate': False,
    },
},

【问题讨论】:

    标签: python django http-status-code-400 cookiecutter


    【解决方案1】:

    您是否尝试过 ALLOWED_HOSTS = ['*','yourdomain.com','www.yourdomain.com','123.456.78.91']?

    【讨论】:

    • 是的,我得到了同样的结果。
    • 试试这个 ['127.0.0.1','localhost','www.domain.com','domain.com']
    • 你重启生产服务器了吗?
    • 当然可以。问题可能是使用千篇一律吗?
    猜你喜欢
    • 2013-11-21
    • 2021-10-30
    • 2018-01-07
    • 2016-12-08
    • 2017-01-20
    • 2016-09-11
    • 2021-08-13
    • 2019-07-17
    • 2013-09-27
    相关资源
    最近更新 更多