diff --git a/adjutant/config/django.py b/adjutant/config/django.py index a6c766e..d77ceaa 100644 --- a/adjutant/config/django.py +++ b/adjutant/config/django.py @@ -45,6 +45,22 @@ config_group.register_child_config( unsafe_default=True, ) ) +config_group.register_child_config( + fields.StrConfig( + "secure_proxy_ssl_header", + help_text="The header representing a HTTP header/value combination " + "that signifies a request is secure.", + default="HTTP_X_FORWARDED_PROTO", + ) +) +config_group.register_child_config( + fields.StrConfig( + "secure_proxy_ssl_header_value", + help_text="The value representing a HTTP header/value combination " + "that signifies a request is secure.", + default="https", + ) +) config_group.register_child_config( fields.DictConfig( "databases", diff --git a/adjutant/settings.py b/adjutant/settings.py index 51f8042..5968e74 100644 --- a/adjutant/settings.py +++ b/adjutant/settings.py @@ -114,6 +114,11 @@ if DEBUG: ALLOWED_HOSTS = adj_conf.django.allowed_hosts +SECURE_PROXY_SSL_HEADER = ( + adj_conf.django.secure_proxy_ssl_header, + adj_conf.django.secure_proxy_ssl_header_value +) + DATABASES = adj_conf.django.databases if adj_conf.django.logging: diff --git a/etc/adjutant.yaml b/etc/adjutant.yaml index dff18a2..b17242a 100644 --- a/etc/adjutant.yaml +++ b/etc/adjutant.yaml @@ -9,6 +9,12 @@ django: # The Django allowed hosts allowed_hosts: - '*' + # String + # The header representing a HTTP header/value combination that signifies a request is secure. + secure_proxy_ssl_header: HTTP_X_FORWARDED_PROTO + # String + # The value representing a HTTP header/value combination that signifies a request is secure. + secure_proxy_ssl_header_value: https # Dict # Django databases config. databases: