Reputation: 1105
On my production server I keep getting errors similar to this one
[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: 't17.proxy-checks.com:443'. You may need to add 't17.proxy-checks.com' to ALLOWED_HOSTS.
I don't know why and how this error is coming. Should I ignore these error messages ?
I've added my domain and private IP to the allowed hosts in the settings.py file. I want to know what exactly is this error, are these bots? And whether it's safe to ignore them
Upvotes: 0
Views: 1499
Reputation: 1628
I was using Elastic beanstalk with uWSGI server and load balancer in front of web server. Load balancer redirect requests with dynamic IPs each time. Another reason was, EB was sending request to my app to check app health. These are the 2 common reasons if you are using services like Elastic beanstalk or EC2.
To ignore such errors from sending to ADMINS or logs, i tried this and it worked.
Check Django Docs on this topic for more details
settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
},
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'filters': ['require_debug_false'],
'include_html': True,
},
'null': {
'class': 'logging.NullHandler',
'filters': ['require_debug_false'],
},
},
'loggers': {
'console': {
'handlers': ['console'],
'propagate': True,
},
# Don't send invalid host error messages to ADMINS.
# https://docs.djangoproject.com/en/dev/topics/logging/#django-security
'django.security.DisallowedHost': {
'handlers': ['null'],
'propagate': False,
},
'admins': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
If you don't want to even forward this error to log, move django.security.DisallowedHost
to the top of loggers
. Right now this will move to log but not to ADMINS as propagate=False
Upvotes: 1
Reputation: 1
in the settings of django ALLOWED_HOSTS = ['*']
or something like this ALLOWED_HOSTS = ['t17.proxy-checks.com']
ALLOWED_HOSTS
Upvotes: 0