I don't think that's wise to set allowed hosts to a host you
don't want your application to be accessed by. Django
documentation shows you how you can mute the errors -
https://docs.djangoproject.com/en/2.0/topics/logging/#django-security.
It's not technically an error of your application.
'handlers': { 'null': { 'class': 'logging.NullHandler', }, }, 'loggers': { 'django.security.DisallowedHost': { 'handlers': ['null'], 'propagate': False, }, },Maybe you could restrict host headers at the nginx layer, but I don't think it's worth your effort... Maybe you should use some smarter solution for receiving errors like Sentry where you only get notified once about an error and you can mute them instead of relying on each error occurrence triggering an email :P
On zondag 1 juli 2018 19:10:15 CEST Tomasz Knapik wrote:
> Maybe you could restrict host headers at the nginx layer, but I don't
> think it's worth your effort...
If you think of it like that it seems like a lot of work. But if you simply setup a default server that redirects to the actual Django server with correct hostname, then all you need is 2 server blocks: 1 default, 1 with correct `server_name`.
See Request Processing for more background information and tricks.
--
Melvyn Sopacua