1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-12 10:45:38 +02:00

Merge pull request #373 from mildred/master

Add parameters to specify hosts for various containers
This commit is contained in:
kaiyou 2018-01-27 11:26:59 +01:00 committed by GitHub
commit 8cee04dbcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 9 deletions

View File

@ -54,6 +54,11 @@ default_config = {
'WEB_WEBMAIL': '/webmail',
# Advanced settings
'PASSWORD_SCHEME': 'SHA512-CRYPT',
# Host settings
'HOST_IMAP': 'imap',
'HOST_POP3': 'imap',
'HOST_SMTP': 'smtp',
'HOST_AUTHSMTP': os.environ.get('HOST_SMTP', 'smtp'),
}
# Load configuration from the environment if available

View File

@ -1,5 +1,6 @@
from mailu import db, models
from mailu import db, models, app
import re
import socket
import urllib
@ -73,14 +74,19 @@ def get_status(protocol, status):
status, codes = STATUSES[status]
return status, codes[protocol]
def extract_host_port(host_and_port, default_port):
host, _, port = re.match('^(.*)(:([0-9]*))?$', host_and_port).groups()
return host, int(port) if port else default_port
def get_server(protocol, authenticated=False):
if protocol == "imap":
hostname, port = "imap", 143
hostname, port = extract_host_port(app.config['HOST_IMAP'], 143)
elif protocol == "pop3":
hostname, port = "imap", 110
hostname, port = extract_host_port(app.config['HOST_POP3'], 110)
elif protocol == "smtp":
hostname = "smtp"
port = 10025 if authenticated else 25
if authenticated:
hostname, port = extract_host_port(app.config['HOST_AUTHSMTP'], 10025)
else:
hostname, port = extract_host_port(app.config['HOST_SMTP'], 25)
address = socket.gethostbyname(hostname)
return address, port

View File

@ -37,10 +37,10 @@ http {
# Main HTTP server
server {
# Variables for proxifying
set $admin admin;
set $antispam antispam:11334;
set $webmail webmail;
set $webdav webdav:5232;
set $admin {{ HOST_ADMIN }};
set $antispam {{ HOST_ANTISPAM }};
set $webmail {{ HOST_WEBMAIL }};
set $webdav {{ HOST_WEBDAV }};
# Always listen over HTTP
listen 80;

View File

@ -12,6 +12,14 @@ with open("/etc/resolv.conf") as handle:
content = handle.read().split()
args["RESOLVER"] = content[content.index("nameserver") + 1]
if "HOST_WEBMAIL" not in args:
args["HOST_WEBMAIL"] = "webmail"
if "HOST_ADMIN" not in args:
args["HOST_ADMIN"] = "admin"
if "HOST_WEBDAV" not in args:
args["HOST_WEBDAV"] = "webdav:5232"
if "HOST_ANTISPAM" not in args:
args["HOST_ANTISPAM"] = "antispam:11334"
# TLS configuration
args["TLS"] = {

View File

@ -69,3 +69,21 @@ Advanced settings
The ``PASSWORD_SCHEME`` is the password encryption scheme. You should use the
default value, unless you are importing password from a separate system and
want to keep using the old password encryption scheme.
Infrastructure settings
-----------------------
Various environment variables ``HOST_*`` can be used to run Mailu containers
separately from a supported orchestrator. It is used by the various components
to find the location of the other containers it depends on. They can contain an
optional port number. Those variables are:
- ``HOST_IMAP``: the container that is running the IMAP server (default: ``imap``, port 143)
- ``HOST_POP3``: the container that is running the POP3 server (default: ``imap``, port 110)
- ``HOST_SMTP``: the container that is running the SMTP server (default: ``smtp``, port 25)
- ``HOST_AUTHSMTP``: the container that is running the authenticated SMTP server for the webnmail (default: ``smtp``, port 10025)
- ``HOST_ADMIN``: the container that is running the admin interface (default: ``admin``)
- ``HOST_ANTISPAM``: the container that is running the antispam service (default: ``antispam:11334``)
- ``HOST_WEBMAIL``: the container that is running the webmail (default: ``webmail``)
- ``HOST_WEBDAV``: the container that is running the webdav server (default: ``webdav:5232``)