{% extends "bundles/TwigBundle/Exception/error.html.twig" %}
{% set untrusted_host = exception.message starts with 'Untrusted Host' or exception.message starts with 'Invalid Host' %}
{% set seen_host = untrusted_host ? (exception.message|split('"'))[1]|default(null) : null %}
{% block status_comment %}
{% if untrusted_host %}
Part-DB was accessed using a host name that is not marked as trusted.
{% if seen_host %}
The host name Part-DB saw was: {{ seen_host }}
{% else %}
{{ exception.message }}
{% endif %}
{% else %}
Your browser sent a request that the server could not understand.
{% endif %}
{% endblock %}
{% block admin_info %}
{% if untrusted_host %}
Untrusted host name.
For security reasons (to prevent HTTP Host header attacks), Part-DB only responds to requests using host names that were explicitly marked as trusted, once more than one host name is used to access it (e.g. behind a reverse proxy).
Try following things:
TRUSTED_HOSTS environment variable in your .env.local file (or your docker-compose environment) to a regular expression matching all host names Part-DB should be reachable under, e.g.
{% if seen_host %}
TRUSTED_HOSTS='^({{ seen_host|replace({'.': '\\.'}) }})$' (if {{ seen_host }} is a host name you trust)
{% else %}
TRUSTED_HOSTS='^(localhost|example\.com)$'
{% endif %}
TRUSTED_PROXIES is configured correctly, so the original host name is forwarded properly.