mirror of
https://github.com/Mailu/Mailu.git
synced 2025-05-29 23:07:50 +02:00
Merge pull request #373 from mildred/master
Add parameters to specify hosts for various containers
This commit is contained in:
commit
8cee04dbcc
@ -54,6 +54,11 @@ default_config = {
|
|||||||
'WEB_WEBMAIL': '/webmail',
|
'WEB_WEBMAIL': '/webmail',
|
||||||
# Advanced settings
|
# Advanced settings
|
||||||
'PASSWORD_SCHEME': 'SHA512-CRYPT',
|
'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
|
# Load configuration from the environment if available
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from mailu import db, models
|
from mailu import db, models, app
|
||||||
|
|
||||||
|
import re
|
||||||
import socket
|
import socket
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
@ -73,14 +74,19 @@ def get_status(protocol, status):
|
|||||||
status, codes = STATUSES[status]
|
status, codes = STATUSES[status]
|
||||||
return status, codes[protocol]
|
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):
|
def get_server(protocol, authenticated=False):
|
||||||
if protocol == "imap":
|
if protocol == "imap":
|
||||||
hostname, port = "imap", 143
|
hostname, port = extract_host_port(app.config['HOST_IMAP'], 143)
|
||||||
elif protocol == "pop3":
|
elif protocol == "pop3":
|
||||||
hostname, port = "imap", 110
|
hostname, port = extract_host_port(app.config['HOST_POP3'], 110)
|
||||||
elif protocol == "smtp":
|
elif protocol == "smtp":
|
||||||
hostname = "smtp"
|
if authenticated:
|
||||||
port = 10025 if authenticated else 25
|
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)
|
address = socket.gethostbyname(hostname)
|
||||||
return address, port
|
return address, port
|
||||||
|
@ -37,10 +37,10 @@ http {
|
|||||||
# Main HTTP server
|
# Main HTTP server
|
||||||
server {
|
server {
|
||||||
# Variables for proxifying
|
# Variables for proxifying
|
||||||
set $admin admin;
|
set $admin {{ HOST_ADMIN }};
|
||||||
set $antispam antispam:11334;
|
set $antispam {{ HOST_ANTISPAM }};
|
||||||
set $webmail webmail;
|
set $webmail {{ HOST_WEBMAIL }};
|
||||||
set $webdav webdav:5232;
|
set $webdav {{ HOST_WEBDAV }};
|
||||||
|
|
||||||
# Always listen over HTTP
|
# Always listen over HTTP
|
||||||
listen 80;
|
listen 80;
|
||||||
|
@ -12,6 +12,14 @@ with open("/etc/resolv.conf") as handle:
|
|||||||
content = handle.read().split()
|
content = handle.read().split()
|
||||||
args["RESOLVER"] = content[content.index("nameserver") + 1]
|
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
|
# TLS configuration
|
||||||
args["TLS"] = {
|
args["TLS"] = {
|
||||||
|
@ -69,3 +69,21 @@ Advanced settings
|
|||||||
The ``PASSWORD_SCHEME`` is the password encryption scheme. You should use the
|
The ``PASSWORD_SCHEME`` is the password encryption scheme. You should use the
|
||||||
default value, unless you are importing password from a separate system and
|
default value, unless you are importing password from a separate system and
|
||||||
want to keep using the old password encryption scheme.
|
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``)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user