docker-scripts-archived / freedombox

Docker scripts that install FreedomBox (https://wiki.debian.org/FreedomBox) (Moved to: https://gitlab.com/docker-scripts/freedombox)
GNU General Public License v3.0
3 stars 5 forks source link

django.security.DisallowedHost ERROR when opening website through wsproxy #4

Closed RadZaeem closed 6 years ago

RadZaeem commented 6 years ago

After installing latest plinth from debian salsa, and configuring /etc/hosts to include plinth.example.org, I got this error from plinth.__main__.py when I open https://plinth.example.org/plinth

django.security.DisallowedHost ERROR    Invalid HTTP_HOST header: 'plinth.example.org, plinth.example.org'. The domain name provided is not valid according to RFC 1034/1035.

If I open https://localhost/plinth with w3m after ds shell into container, I can access the web UI and continue freedombox-setup normally.

Will need to look into how wsproxy handles http headers

RadZaeem commented 6 years ago

Finally can access it via wsproxy https://user-images.githubusercontent.com/4066712/39434444-88133944-4cd3-11e8-915c-f85286e22d04.png

P2P connection also works fine: https://user-images.githubusercontent.com/4066712/39434905-e6cb4b6a-4cd4-11e8-8791-9ea8fd53a625.png

Need to edit plinth/data/etc/plinth/plinth.config first. Since we are using wsproxy for now it is safe. I need to make sed command to write this with bash

# Enable the following only if Plinth is behind a proxy server.  The
# proxy server should properly clean and the following HTTP headers:
#   X-Forwarded-Host
#   X-Forwarded-Proto
# If you enable these unnecessarily, this will lead to serious security
# problems. For more information, see
# https://docs.djangoproject.com/en/1.7/ref/settings/
#
# These are enabled by default in Plinth because the default
# configuration allows only connections from localhost
#

use_x_forwarded_host = False #True
secure_proxy_ssl_header = None #HTTP_X_FORWARDED_PROTO
dashohoxha commented 6 years ago

Will need to look into how wsproxy handles http headers

wsproxy makes an apache2 proxy redirection to the freedombox container. Inside the freedombox container there is another apache2 proxy redirection to plinth. Because of these two redirections the HTTP_HOST header is plinth.example.org, plinth.example.org, which is considered invalid by django for some reason.