diff --git a/docs/configuration.md b/docs/configuration.md index bde170e5c..cb5af9d86 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -322,8 +322,7 @@ You can read more about this in [the Django project's documentation](https://doc Can also be set using PAPERLESS_URL (see above). - If manually set, please remember to include "localhost". Otherwise - docker healthcheck will fail. + "localhost" is always allowed for docker healthcheck Defaults to "\*", which is all hosts. diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 0301fffad..122806516 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -422,11 +422,12 @@ if _paperless_url: _paperless_uri = urlparse(_paperless_url) CSRF_TRUSTED_ORIGINS.append(_paperless_url) CORS_ALLOWED_ORIGINS.append(_paperless_url) - if ["*"] != ALLOWED_HOSTS: + +if ["*"] != ALLOWED_HOSTS: + # always allow localhost. Necessary e.g. for healthcheck in docker. + ALLOWED_HOSTS.append("localhost") + if _paperless_url: ALLOWED_HOSTS.append(_paperless_uri.hostname) - else: - # always allow localhost. Necessary e.g. for healthcheck in docker. - ALLOWED_HOSTS = [_paperless_uri.hostname] + ["localhost"] # For use with trusted proxies TRUSTED_PROXIES = __get_list("PAPERLESS_TRUSTED_PROXIES")