Skip to content

DJANGO_ALLOWED_HOSTS only allows for 1 host #637

@raph-topo

Description

@raph-topo

Tag/version of Container Images
0.4.5

Bug

services:
  web:
    environment:
      - DJANGO_ALLOWED_HOSTS=host1.example.com,host2.example.com

results in error `Invalid HTTP_HOST header: 'host1.example.com'. You may need to add 'host1.example.com' to ALLOWED_HOSTS.

Reason

In \opt\mailman-web\settings.py

ALLOWED_HOSTS = [
    "localhost",  # Archiving API from Mailman, keep it.
    # "lists.your-domain.org",
    # Add here all production URLs you may have.
    "mailman-web",
    gethostbyname("mailman-web"),
    os.environ.get('SERVE_FROM_DOMAIN'),
    os.environ.get('DJANGO_ALLOWED_HOSTS'),
]

reads the env var as a string (instead of parsing a comma-separated list), which mangles the array ALLOWED_HOSTS:

['localhost',
'mailman-web',
'192.168.64.4',
'host1.example.com',
'host1.example.com,host2.example.com']

Workaround

Override in settings_local.py:

ALLOWED_HOSTS = ['localhost','mailman-web','host1.example.com','host2.example.com']

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions