Add allowed hosts using environment vars.

This commit is contained in:
Abhilash Raj
2017-09-30 21:31:59 -07:00
committed by Abhilash Raj
parent afb8f09eff
commit eca79c9858
2 changed files with 17 additions and 4 deletions

View File

@@ -54,6 +54,10 @@ change them unless you know what you want.
- `DJANGO_LOG_URL`: Path to the django's log file. Defaults to - `DJANGO_LOG_URL`: Path to the django's log file. Defaults to
`/opt/mailman-web-data/logs/mailmanweb.log`. `/opt/mailman-web-data/logs/mailmanweb.log`.
- `DJANGO_ALLOWED_HOSTS`: Entry to add to ALLOWED_HOSTS in Django
configuration. This is a separate configuration from`SERVE_FROM_DOMAIN` as
latter is used for other purposes too.
Running Running
======= =======

View File

@@ -52,6 +52,7 @@ ALLOWED_HOSTS = [
"mailman-web", "mailman-web",
"172.19.199.3", "172.19.199.3",
os.environ.get('SERVE_FROM_DOMAIN'), os.environ.get('SERVE_FROM_DOMAIN'),
os.environ.get('DJANGO_ALLOWED_HOSTS'),
] ]
# Mailman API credentials # Mailman API credentials
@@ -212,10 +213,11 @@ LOGIN_URL = 'account_login'
LOGIN_REDIRECT_URL = 'list_index' LOGIN_REDIRECT_URL = 'list_index'
LOGOUT_URL = 'account_logout' LOGOUT_URL = 'account_logout'
DEFAULT_FROM_EMAIL = 'postorius@localhost.local'
# Use SERVE_FROM_DOMAIN as the default domain in the email.
SERVER_EMAIL = 'root@localhost.local' hostname = os.environ.get('SERVE_FROM_DOMAIN', 'localhost.local')
DEFAULT_FROM_EMAIL = 'postorius@{}'.format(hostname)
SERVER_EMAIL = 'root@{}'.format(hostname)
# Change this when you have a real email backend # Change this when you have a real email backend
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
@@ -307,6 +309,7 @@ HAYSTACK_CONNECTIONS = {
}, },
} }
import sys
# A sample logging configuration. The only tangible logging # A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to # performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False. # the site admins on every HTTP 500 error when DEBUG=False.
@@ -336,6 +339,8 @@ LOGGING = {
'console': { 'console': {
'class': 'logging.StreamHandler', 'class': 'logging.StreamHandler',
'formatter': 'simple', 'formatter': 'simple',
'level': 'INFO',
'stream': sys.stdout,
}, },
# TODO: use an environment variable $DJ_LOG_URL to configure the logging # TODO: use an environment variable $DJ_LOG_URL to configure the logging
# using an environment variable. # using an environment variable.
@@ -357,8 +362,9 @@ LOGGING = {
'propagate': True, 'propagate': True,
}, },
'postorius': { 'postorius': {
'handlers': ['console', 'file'], 'handlers': ['file'],
'level': 'INFO', 'level': 'INFO',
'propagate': True
}, },
}, },
'formatters': { 'formatters': {
@@ -376,6 +382,9 @@ LOGGING = {
} }
if os.environ.get('LOG_TO_CONSOLE') == 'yes':
LOGGING['loggers']['django']['handlers'].append('console')
LOGGING['loggers']['django.request']['handlers'].append('console')
# HyperKitty-specific # HyperKitty-specific
# #
# Only display mailing-lists from the same virtual host as the webserver # Only display mailing-lists from the same virtual host as the webserver