From c0a997f2fabe002e446a711997a7ee1f5b35fe84 Mon Sep 17 00:00:00 2001 From: Anders Schau Knatten Date: Fri, 5 Apr 2024 09:25:31 -0700 Subject: [PATCH] Stop spamming about invalid http hosts After moving to the new server where everyone can reach the IP/port that Django itself is running on, we get a bunch of errors like these whenever someone tries to use an invalid host: > [Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: '(...)'. You > may need to add '(...)' to ALLOWED_HOSTS. There's no point in looking at these, the only allowed host we care about is already configured. And since we don't control the http server, we can't block these requests before they hit Django. --- cppquiz/settings.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cppquiz/settings.py b/cppquiz/settings.py index 20a4245..675eabc 100644 --- a/cppquiz/settings.py +++ b/cppquiz/settings.py @@ -158,8 +158,15 @@ 'filename': here('quiz.log'), 'formatter': 'simple_stamped', }, + 'null': { + 'class': 'logging.NullHandler', + }, }, 'loggers': { + 'django.security.DisallowedHost': { + 'handlers': ['null'], + 'propagate': False, + }, 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR',