Get rid of hard coded IPs (#441)
Replace them with: * containers' hostnames * gateway's IP address for default SMTP_HOST * Core: when SMTP_HOST undef, echo the default value * docker-compose: add port mapping * docker-compose: drop network driver conf * Exim macro: use localhost as LMTP host * Update README.md * docker-compose: Limit port mapping to loopback * Update other docker-compose example files
This commit is contained in:
@@ -43,11 +43,12 @@ change them unless you know what you want.
|
||||
- `MAILMAN_REST_PASSWORD`: Mailman's REST API user's password. Default value is
|
||||
`restpass`
|
||||
|
||||
- `MAILMAN_HOST_IP`: IP of the Container from which Mailman will send emails to
|
||||
hyperkitty (django). Set to `172.19.199.2` by default.
|
||||
- `MAILMAN_HOSTNAME`: IP of the Container from which Mailman will send emails to
|
||||
hyperkitty (django). Set to `mailman-core` by default.
|
||||
|
||||
- `SMTP_HOST`: IP Address/hostname from which you will be sending
|
||||
emails. Default value is `172.19.199.1`, which is the address of the Host OS.
|
||||
emails. Default value is the container's gateway retrieved from:
|
||||
/sbin/ip route | awk '/default/ { print $3 }'
|
||||
|
||||
- `SMTP_PORT`: Port used for SMTP. Default is `25`.
|
||||
|
||||
|
||||
@@ -53,6 +53,11 @@ function check_or_create () {
|
||||
# END
|
||||
# }
|
||||
|
||||
# SMTP_HOST defaults to the gateway
|
||||
if [[ ! -v SMTP_HOST ]]; then
|
||||
export SMTP_HOST=$(/sbin/ip route | awk '/default/ { print $3 }')
|
||||
fi
|
||||
|
||||
# Check if $SECRET_KEY is defined, if not, bail out.
|
||||
if [[ ! -v SECRET_KEY ]]; then
|
||||
echo "SECRET_KEY is not defined. Aborting."
|
||||
|
||||
@@ -29,6 +29,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
|
||||
import os
|
||||
import dj_database_url
|
||||
import sys
|
||||
from socket import gethostbyname
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
@@ -51,7 +52,7 @@ ALLOWED_HOSTS = [
|
||||
# "lists.your-domain.org",
|
||||
# Add here all production URLs you may have.
|
||||
"mailman-web",
|
||||
"172.19.199.3",
|
||||
gethostbyname("mailman-web"),
|
||||
os.environ.get('SERVE_FROM_DOMAIN'),
|
||||
os.environ.get('DJANGO_ALLOWED_HOSTS'),
|
||||
]
|
||||
@@ -61,7 +62,7 @@ MAILMAN_REST_API_URL = os.environ.get('MAILMAN_REST_URL', 'http://mailman-core:8
|
||||
MAILMAN_REST_API_USER = os.environ.get('MAILMAN_REST_USER', 'restadmin')
|
||||
MAILMAN_REST_API_PASS = os.environ.get('MAILMAN_REST_PASSWORD', 'restpass')
|
||||
MAILMAN_ARCHIVER_KEY = os.environ.get('HYPERKITTY_API_KEY')
|
||||
MAILMAN_ARCHIVER_FROM = (os.environ.get('MAILMAN_HOST_IP', '172.19.199.2'),)
|
||||
MAILMAN_ARCHIVER_FROM = (os.environ.get('MAILMAN_HOST_IP', gethostbyname(os.environ.get('MAILMAN_HOSTNAME', 'mailman-core'))),)
|
||||
|
||||
# Application definition
|
||||
|
||||
@@ -227,7 +228,7 @@ SERVER_EMAIL = 'root@{}'.format(hostname)
|
||||
|
||||
# Change this when you have a real email backend
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
EMAIL_HOST = os.environ.get('SMTP_HOST', '172.19.199.1')
|
||||
EMAIL_HOST = os.environ.get('SMTP_HOST', '')
|
||||
EMAIL_PORT = os.environ.get('SMTP_PORT', 25)
|
||||
EMAIL_HOST_USER = os.environ.get('SMTP_HOST_USER', '')
|
||||
EMAIL_HOST_PASSWORD = os.environ.get('SMTP_HOST_PASSWORD', '')
|
||||
|
||||
Reference in New Issue
Block a user