I continuously receive `Invalid HTTP_HOST header` error email after I upgrade my django site from http to https

后端 未结 3 921
醉梦人生
醉梦人生 2020-12-09 09:24

Recently, I upgrade one of my django sites from http to https. However, after that, I continuously receive Invalid HTTP_HOST header error email while before I n

3条回答
  •  天命终不由人
    2020-12-09 10:12

    This is probably because there may be bot scripts running which are targeting your server with different HTTP_HOST headers (this is common). and in django you have Allowed Hosts set to a particular host. So if a Host Header different from one specified in Allowed Hosts come then django would give 400 error. By default django loggers are configured to send mail on each error. To stop getting the mails you need to configure loggers in django and add the following logger 'django.security.DisallowedHost': { 'handlers': ['null'], 'propagate': False, },

    Refer https://www.calazan.com/how-to-disable-the-invalid-http_host-header-emails-in-django/

提交回复
热议问题