cobbler – DisallowedHost: Invalid HTTP_HOST header: ”. You may need to add u” to ALLOWED_HOSTS.

Cobbler web (probably not the latest) uses Django and since version 1.5 (IIUC) if your IP is not in an allowed host directive – ALLOWED_HOSTS you will get 400 and the following apache errors:

[Mon Jan 14 13:44:27.805290 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685] mod_wsgi (pid=5897): Exception occurred processing WSGI script '/usr/share/cobbler/web/cobbler.wsgi'.
.....
.....
[Mon Jan 14 13:44:27.805743 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685] DisallowedHost: Invalid HTTP_HOST header: '192.168.0.25'. You may need to add u'192.168.0.25' to ALLOWED_HOSTS.

The solution is simple enough – add your host in the ALLOWED_HOSTS.

But where? In which cobbler configuration file?

Find the cobbler web setting file and add a line for ALLOWED_HOSTS.

In Ubuntu the file is “/usr/share/cobbler/web/settings.py” and add the following:

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ALLOWED_HOSTS = '*'

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

This will instruct Django to accept requests from all IPs. Now Cobbler web will work.

The whole output error in the apache logs

The error could be seen in Cobbler web installed in Ubuntu 16 with the latest package cobbler-web 2.4.1-0ubuntu2.

[Mon Jan 14 13:44:27.805290 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685] mod_wsgi (pid=5897): Exception occurred processing WSGI script '/usr/share/cobbler/web/cobbler.wsgi'.
[Mon Jan 14 13:44:27.805360 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685] Traceback (most recent call last):
[Mon Jan 14 13:44:27.805381 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 189, in __call__
[Mon Jan 14 13:44:27.805420 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     response = self.get_response(request)
[Mon Jan 14 13:44:27.805429 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 207, in get_response
[Mon Jan 14 13:44:27.805442 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     return debug.technical_500_response(request, *sys.exc_info(), status_code=400)
[Mon Jan 14 13:44:27.805449 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/views/debug.py", line 97, in technical_500_response
[Mon Jan 14 13:44:27.805463 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     html = reporter.get_traceback_html()
[Mon Jan 14 13:44:27.805470 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/views/debug.py", line 384, in get_traceback_html
[Mon Jan 14 13:44:27.805480 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     return t.render(c)
[Mon Jan 14 13:44:27.805487 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 210, in render
[Mon Jan 14 13:44:27.805499 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     return self._render(context)
[Mon Jan 14 13:44:27.805505 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 202, in _render
[Mon Jan 14 13:44:27.805516 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     return self.nodelist.render(context)
[Mon Jan 14 13:44:27.805523 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 905, in render
[Mon Jan 14 13:44:27.805533 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     bit = self.render_node(node, context)
[Mon Jan 14 13:44:27.805551 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/debug.py", line 79, in render_node
[Mon Jan 14 13:44:27.805563 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     return node.render(context)
[Mon Jan 14 13:44:27.805569 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/defaulttags.py", line 329, in render
[Mon Jan 14 13:44:27.805582 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     return nodelist.render(context)
[Mon Jan 14 13:44:27.805589 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 905, in render
[Mon Jan 14 13:44:27.805602 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     bit = self.render_node(node, context)
[Mon Jan 14 13:44:27.805609 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/debug.py", line 79, in render_node
[Mon Jan 14 13:44:27.805621 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     return node.render(context)
[Mon Jan 14 13:44:27.805627 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/debug.py", line 89, in render
[Mon Jan 14 13:44:27.805639 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     output = self.filter_expression.resolve(context)
[Mon Jan 14 13:44:27.805647 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 648, in resolve
[Mon Jan 14 13:44:27.805657 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     obj = self.var.resolve(context)
[Mon Jan 14 13:44:27.805663 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 789, in resolve
[Mon Jan 14 13:44:27.805673 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     value = self._resolve_lookup(context)
[Mon Jan 14 13:44:27.805679 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 849, in _resolve_lookup
[Mon Jan 14 13:44:27.805689 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     current = current()
[Mon Jan 14 13:44:27.805696 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/http/request.py", line 152, in build_absolute_uri
[Mon Jan 14 13:44:27.805708 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     host=self.get_host(),
[Mon Jan 14 13:44:27.805714 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]   File "/usr/lib/python2.7/dist-packages/django/http/request.py", line 102, in get_host
[Mon Jan 14 13:44:27.805725 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685]     raise DisallowedHost(msg)
[Mon Jan 14 13:44:27.805743 2019] [wsgi:error] [pid 5897:tid 139760386561792] [remote 192.168.0.250:44685] DisallowedHost: Invalid HTTP_HOST header: '192.168.0.25'. You may need to add u'192.168.0.25' to ALLOWED_HOSTS.