{% extends 'workflows/base_shell.html' %} {% load static i18n %} {% block title %}{% trans "Host & Domain Setup" %}{% endblock %} {% block extra_css %} {% endblock %} {% block shell_body %} {% include 'workflows/includes/app_header.html' with header_show_home=1 header_inside_shell=1 %}

{% trans "Host & Domain Setup" %}

{% trans "Reference for configuring hostnames and origins correctly in Django deployments, including how to fix Invalid HTTP_HOST errors." %}

{% trans "Why this error happens" %}

{% trans "Django rejects requests whose Host header is not present in ALLOWED_HOSTS. This validation runs before normal page routing, so a broken hostname cannot show a friendly in-app error page on that same host." %}

{% trans "Use this guide from a working hostname or IP address to correct the environment configuration." %}

{% trans "Recommended environment variables" %}

{% trans "The application automatically adds APP_DOMAIN and the hostname from APP_BASE_URL to the effective host allow-list. APP_BASE_URL is also added to trusted CSRF origins." %}

{% trans "Current test deployment example" %}

APP_DOMAIN=workdock.bostame.de
APP_BASE_URL=https://workdock.bostame.de
DJANGO_ALLOWED_HOSTS=192.168.2.55,localhost,127.0.0.1
DJANGO_CSRF_TRUSTED_ORIGINS=http://192.168.2.55:8088,https://workdock.bostame.de

{% trans "Production example" %}

APP_DOMAIN=workdock.example.com
APP_BASE_URL=https://workdock.example.com
DJANGO_ALLOWED_HOSTS=workdock.example.com
DJANGO_CSRF_TRUSTED_ORIGINS=https://workdock.example.com

{% trans "Production should run with HTTPS, DEBUG disabled, secure cookies enabled, and SSL redirect enabled." %}

{% trans "How to fix a live server" %}

  1. {% trans "Log into the server and edit the active env file, for example" %} /opt/workdock/.env.test
  2. {% trans "Set APP_DOMAIN and APP_BASE_URL to the real external hostname." %}
  3. {% trans "Keep the local IP in DJANGO_ALLOWED_HOSTS if you still use direct IP access." %}
  4. {% trans "Restart the stack or rerun the deployment script." %}
cd /opt/workdock
nano .env.test
RUN_DJANGO_CHECK=0 DEPLOY_HEALTH_URL="http://127.0.0.1:8088/healthz/" ./scripts/deploy_stack.sh .env.test docker-compose.prod.yml

{% trans "Important rules" %}

{% endblock %}