Some last changes

master
andryyy 2016-12-12 21:53:58 +01:00
parent 64d92e504a
commit 5e883b6f51
22 changed files with 84 additions and 160 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
data/db/mysql/* data/db/mysql/*
data/assets/ssl/*
!data/assets/ssl/.empty
!data/db/mysql/.mysql_data !data/db/mysql/.mysql_data
data/db/redis/* data/db/redis/*
!data/db/redis/.redis_data !data/db/redis/.redis_data

16
000-build-certs.sh 100755
View File

@ -0,0 +1,16 @@
#!/bin/bash
. mailcow.conf
openssl dhparam -out data/assets/ssl/dhparams.pem 2048
docker run \
--rm \
-v ${PWD}/data/assets/ssl:/certs \
ehazlett/certm \
-d /certs ca generate -o=mailcow
docker run \
--rm \
-v ${PWD}/data/assets/ssl:/certs \
ehazlett/certm \
-d /certs client generate --common-name=${MAILCOW_HOSTNAME} -o=mailcow

View File

@ -25,12 +25,9 @@ else
build build
fi fi
sed -i "s#allow-from.*#allow-from=127.0.0.0/8 ${DOCKER_SUBNET}#" data/conf/pdns/recursor.conf
docker run \ docker run \
-v ${PWD}/data/conf/pdns/:/etc/powerdns/ \ -v ${PWD}/data/conf/pdns/:/etc/powerdns/ \
--network=${DOCKER_NETWORK} \ --network=${DOCKER_NETWORK} \
--network-alias pdns \
-h pdns \ -h pdns \
--name ${NAME} \ --name ${NAME} \
-d pdns -d pdns

View File

@ -83,12 +83,11 @@ fi
docker run \ docker run \
-v ${PWD}/data/db/mysql/:/var/lib/mysql/ \ -v ${PWD}/data/db/mysql/:/var/lib/mysql/ \
-v ${PWD}/data/conf/mysql/:/etc/mysql/conf.d/ \ -v ${PWD}/data/conf/mysql/:/etc/mysql/conf.d/:ro \
-v ${PWD}/data/assets/mysql:/assets \ -v ${PWD}/data/assets/mysql:/assets:ro \
--name=${NAME} \ --name=${NAME} \
--network=${DOCKER_NETWORK} \ --network=${DOCKER_NETWORK} \
-h mysql \ -h mysql \
--network-alias mysql \
-e MYSQL_ROOT_PASSWORD=${DBROOT} \ -e MYSQL_ROOT_PASSWORD=${DBROOT} \
-e MYSQL_DATABASE=${DBNAME} \ -e MYSQL_DATABASE=${DBNAME} \
-e MYSQL_USER=${DBUSER} \ -e MYSQL_USER=${DBUSER} \

View File

@ -34,6 +34,5 @@ docker run \
-v ${PWD}/data/db/redis/:/data/ \ -v ${PWD}/data/db/redis/:/data/ \
--network=${DOCKER_NETWORK} \ --network=${DOCKER_NETWORK} \
-h redis \ -h redis \
--network-alias redis \
--name=${NAME} \ --name=${NAME} \
-d redis:${REDISVERS} --appendonly yes -d redis:${REDISVERS} --appendonly yes

View File

@ -32,15 +32,14 @@ else
fi fi
docker run \ docker run \
-v ${PWD}/data/conf/rspamd/override.d/:/etc/rspamd/override.d/ \ -v ${PWD}/data/conf/rspamd/override.d/:/etc/rspamd/override.d/ro \
-v ${PWD}/data/conf/rspamd/local.d/:/etc/rspamd/local.d/ \ -v ${PWD}/data/conf/rspamd/local.d/:/etc/rspamd/local.d/ro \
-v ${PWD}/data/conf/rspamd/lua/:/etc/rspamd/lua/ \ -v ${PWD}/data/conf/rspamd/lua/:/etc/rspamd/lua/:ro \
-v ${PWD}/data/dkim/txt/:/etc/rspamd/dkim/txt/:ro \ -v ${PWD}/data/dkim/txt/:/etc/rspamd/dkim/txt/:ro \
-v ${PWD}/data/dkim/keys/:/etc/rspamd/dkim/keys/:ro \ -v ${PWD}/data/dkim/keys/:/etc/rspamd/dkim/keys/:ro \
--dns=${PDNS_IP} \ --dns=${PDNS_IP} \
--dns-search=${DOCKER_NETWORK} \ --dns-search=${DOCKER_NETWORK} \
--network=${DOCKER_NETWORK} \ --network=${DOCKER_NETWORK} \
--network-alias rspamd \
-h rspamd \ -h rspamd \
--name ${NAME} \ --name ${NAME} \
-d rspamd -d rspamd

View File

@ -22,10 +22,12 @@ docker run \
-v ${PWD}/data/conf/rspamd/dynmaps:/dynmaps:ro \ -v ${PWD}/data/conf/rspamd/dynmaps:/dynmaps:ro \
-v ${PWD}/data/dkim/:/shared/dkim/ \ -v ${PWD}/data/dkim/:/shared/dkim/ \
-d --network=${DOCKER_NETWORK} \ -d --network=${DOCKER_NETWORK} \
--name ${NAME} --network-alias phpfpm -h phpfpm php:${PHPVERS} --name ${NAME} \
-h phpfpm \
php:${PHPVERS}
echo "Installing intl and mysql pdo extension..." echo "Installing intl and mysql pdo extension..."
docker exec ${NAME} /bin/bash -c "apt-get update && apt-get install -y zlib1g-dev libicu-dev g++ libidn11-dev dovecot-core" docker exec ${NAME} /bin/bash -c "apt-get update && apt-get install -y zlib1g-dev libicu-dev g++ libidn11-dev"
docker exec ${NAME} docker-php-ext-configure intl pdo pdo_mysql docker exec ${NAME} docker-php-ext-configure intl pdo pdo_mysql
docker exec ${NAME} docker-php-ext-install intl pdo pdo_mysql docker exec ${NAME} docker-php-ext-install intl pdo pdo_mysql
echo "Restarting container..." echo "Restarting container..."

View File

@ -31,7 +31,6 @@ docker run \
-v ${PWD}/data/assets/ssl/:/etc/ssl/mail/:ro \ -v ${PWD}/data/assets/ssl/:/etc/ssl/mail/:ro \
-v ${PWD}/data/conf/nginx/:/etc/nginx/conf.d/:ro \ -v ${PWD}/data/conf/nginx/:/etc/nginx/conf.d/:ro \
--network=${DOCKER_NETWORK} \ --network=${DOCKER_NETWORK} \
--network-alias nginx \
-h nginx \ -h nginx \
-d nginx:${NGINXVERS} -d nginx:${NGINXVERS}

View File

@ -26,9 +26,8 @@ else
fi fi
docker run \ docker run \
-v ${PWD}/data/conf/rmilter/:/etc/rmilter.conf.d/ \ -v ${PWD}/data/conf/rmilter/:/etc/rmilter.conf.d/:ro \
--network=${DOCKER_NETWORK} \ --network=${DOCKER_NETWORK} \
--network-alias rmilter \
-h rmilter \ -h rmilter \
--name ${NAME} \ --name ${NAME} \
-d rmilter -d rmilter

View File

@ -21,6 +21,5 @@ fi
docker run \ docker run \
--network=${DOCKER_NETWORK} \ --network=${DOCKER_NETWORK} \
-h memcached \ -h memcached \
--network-alias memcached \
--name=${NAME} \ --name=${NAME} \
-d memcached -d memcached

View File

@ -7,22 +7,22 @@ All configurations were written with security in mind.
### Exposed ports: ### Exposed ports:
| Service | External bindings | Internal bindings | | Service | Hostname, Alias | External bindings | Internal bindings |
|:----------------------|:---------------------------------------------|:-------------------------------| |:-------------|:-------------------------------|:---------------------------------------------|:-------------------------------|
| Postfix | 25/tcp, 465/tcp, 587/tcp | 588/tcp | | Postfix | ${MAILCOW_HOSTNAME}, postfix | 25/tcp, 465/tcp, 587/tcp | 588/tcp |
| Dovecot | 110/tcp, 143/tcp, 993/tcp, 995/tcp, 4190/tcp | 24/tcp, 10001/tcp | | Dovecot | ${MAILCOW_HOSTNAME}, dovecot | 110/tcp, 143/tcp, 993/tcp, 995/tcp, 4190/tcp | 24/tcp, 10001/tcp |
| Nginx | 443/tcp | 80/tcp, 8081/tcp | | Nginx | nginx | 443/tcp | 80/tcp, 8081/tcp |
| PowerDNS Recursor | - | 53/udp | | PowerDNS | pdns | - | 53/udp |
| Rspamd | - | 11333/tcp, 11334/tcp | | Rspamd | rspamd | - | 11333/tcp, 11334/tcp |
| MariaDB | - | 3306/tcp | | MariaDB | mysql | - | 3306/tcp |
| Rmilter | - | 9000/tcp | | Rmilter | rmilter | - | 9000/tcp |
| PHP FPM | - | 9000/tcp | | PHP FPM | phpfpm | - | 9000/tcp |
| SOGo | - | 9000/tcp | | SOGo | sogo | - | 9000/tcp |
| Redis | - | 6379/tcp | | Redis | redis | - | 6379/tcp |
| Memcached | - | 11211/tcp | | Memcached | memcached | - | 11211/tcp |
All containers share a network ${MAILCOW_NETWORK} (name can be changed, but remove all containers and rebuild them after changing).
All containers share a network "mailcow-network" (name can be changed, but remove all containers and rebuild them after changing). IPs are dynamic and taken from subnet ${DOCKER_SUBNET}.
## Installation ## Installation
@ -59,16 +59,8 @@ docker restart rspamd-mailcow
Open https://${MAILCOW_HOSTNAME}/rspamd in a browser. Open https://${MAILCOW_HOSTNAME}/rspamd in a browser.
### SSL (or: How to use Let's Encrypt) ### SSL (and: How to use Let's Encrypt)
mailcow dockerized comes with a self-signed certificate. Certificates and DH parameters are saved as `data/assets/ssl/{dhparams.pem,mail.{crt,key}}`. mailcow dockerized generates a CA named "mailcow" with a self-signed server certificate in `data/assets/ssl` via `000-build-certs.sh`.
First you should renew the DH parameters.
Soem say you should use 4096, but be prepared for a long waiting period when generating such a file.
Assuming you are in the mailcow root folder:
```
openssl dhparam -out ./data/assets/ssl/dhparams.pem 2048
```
Get the certbot client: Get the certbot client:
``` ```
@ -87,8 +79,8 @@ certbot-auto certonly \
Create hard links to the full path of the new certificates. Assuming you are still in the mailcow root folder: Create hard links to the full path of the new certificates. Assuming you are still in the mailcow root folder:
``` ```
mv data/assets/ssl/mail.{crt,crt_old} mv data/assets/ssl/cert.{pem,pem.backup}
mv data/assets/ssl/mail.{key,key_old} mv data/assets/ssl/key.{pem,pem.backup}
ln $(readlink -f /etc/letsencrypt/live/${MAILCOW_HOSTNAME}/fullchain.pem) data/assets/ssl/mail.crt ln $(readlink -f /etc/letsencrypt/live/${MAILCOW_HOSTNAME}/fullchain.pem) data/assets/ssl/mail.crt
ln $(readlink -f /etc/letsencrypt/live/${MAILCOW_HOSTNAME}/privkey.pem) data/assets/ssl/mail.key ln $(readlink -f /etc/letsencrypt/live/${MAILCOW_HOSTNAME}/privkey.pem) data/assets/ssl/mail.key
``` ```
@ -113,11 +105,11 @@ When renewing certificates, run the last two steps (link + restart) as post-hook
No persistent data is deleted at any time. No persistent data is deleted at any time.
If an image exists, you will be asked wether or not to repull/rebuild it. If an image exists, you will be asked wether or not to repull/rebuild it.
Build files are numbered "nnn" for dependencies.
### Logs ### Logs
You can use docker logs $name for almost all containers. Only rmilter does not log to stdout. You can check rspamd logs for rmilter reponses. You can use docker logs $name for almost all containers. Only rmilter does not log to stdout. You can check rspamd logs for rmilter responses.
When a process dies, the container dies, too. Except for Postfix' container.
### MariaDB ### MariaDB

View File

View File

@ -1,8 +0,0 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAytfW/P+fV4BLTcJhlHG49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hoH0xG9bLJh
0VDZ6bZ7QFLpNxFUlX7muSj8DNsjR77TBuN+Buk+pI68GDl6177Gm6UkZRYx4yi5
xFCP9932L2tufcQaRsiIHdNEFAGMMPe2M22DUmSI0cSNgx4xKuLGJI4PkTM=
-----END RSA PRIVATE KEY-----

View File

@ -183,8 +183,8 @@ service lmtp {
user = vmail user = vmail
} }
listen = *,[::] listen = *,[::]
ssl_cert = </etc/ssl/mail/mail.crt ssl_cert = </etc/ssl/mail/cert.pem
ssl_key = </etc/ssl/mail/mail.key ssl_key = </etc/ssl/mail/key.pem
userdb { userdb {
args = /etc/dovecot/sql/dovecot-mysql.conf args = /etc/dovecot/sql/dovecot-mysql.conf
driver = sql driver = sql

View File

@ -1,8 +1,8 @@
server { server {
listen 443; listen 443;
ssl on; ssl on;
ssl_certificate /etc/ssl/mail/mail.crt; ssl_certificate /etc/ssl/mail/cert.pem;
ssl_certificate_key /etc/ssl/mail/mail.key; ssl_certificate_key /etc/ssl/mail/key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on; ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";

View File

@ -1,4 +1,4 @@
allow-from=127.0.0.0/8 172.18.0.0/16 allow-from=127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8
config-dir=/etc/powerdns config-dir=/etc/powerdns
daemon=no daemon=no
disable-syslog=yes disable-syslog=yes

View File

@ -1,7 +1,7 @@
biff = no biff = no
append_dot_mydomain = no append_dot_mydomain = no
smtpd_tls_cert_file = /etc/ssl/mail/mail.crt smtpd_tls_cert_file = /etc/ssl/mail/cert.pem
smtpd_tls_key_file = /etc/ssl/mail/mail.key smtpd_tls_key_file = /etc/ssl/mail/key.pem
smtpd_use_tls=yes smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
@ -45,8 +45,8 @@ relay_domains = proxy:mysql:/opt/postfix/conf/sql/mysql_virtual_mxdomain_maps.cf
relay_recipient_maps = proxy:mysql:/opt/postfix/conf/sql/mysql_relay_recipient_maps.cf relay_recipient_maps = proxy:mysql:/opt/postfix/conf/sql/mysql_relay_recipient_maps.cf
sender_dependent_default_transport_maps = proxy:mysql:/opt/postfix/conf/sql/mysql_tls_enforce_out_policy.cf sender_dependent_default_transport_maps = proxy:mysql:/opt/postfix/conf/sql/mysql_tls_enforce_out_policy.cf
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_cert_file = /etc/ssl/mail/mail.crt smtp_tls_cert_file = /etc/ssl/mail/cert.pem
smtp_tls_key_file = /etc/ssl/mail/mail.key smtp_tls_key_file = /etc/ssl/mail/key.pem
smtp_tls_loglevel = 1 smtp_tls_loglevel = 1
smtp_dns_support_level = dnssec smtp_dns_support_level = dnssec
smtp_tls_security_level = dane smtp_tls_security_level = dane

View File

@ -1,12 +1,7 @@
<?php <?php
function hash_password($password) { function hash_password($password) {
$salt_str = bin2hex(openssl_random_pseudo_bytes(8)); $salt_str = bin2hex(openssl_random_pseudo_bytes(8));
if ($GLOBALS['HASHING'] == "SHA512-CRYPT") {
return "{SHA512-CRYPT}".crypt($password, '$6$'.$salt_str.'$');
}
else {
return "{SSHA256}".base64_encode(hash('sha256', $password.$salt_str, true).$salt_str); return "{SSHA256}".base64_encode(hash('sha256', $password.$salt_str, true).$salt_str);
}
} }
function hasDomainAccess($username, $role, $domain) { function hasDomainAccess($username, $role, $domain) {
global $pdo; global $pdo;
@ -37,6 +32,23 @@ function hasDomainAccess($username, $role, $domain) {
} }
return false; return false;
} }
function verify_ssha256($password, $hash) {
// Remove tag if any
$hash = ltrim($hash, '{SSHA256}');
// Decode hash
$dhash = base64_decode($hash);
// Get first 32 bytes of binary which equals a SHA256 hash
$ohash = substr($dhash, 0, 32);
// Remove SHA256 hash from decoded hash to get original salt string
$osalt = str_replace($ohash, '', $dhash);
// Check single salted SHA256 hash against extracted hash
if (hash('sha256', $password . $osalt, true) == $ohash) {
return true;
}
else {
return false;
}
}
function doveadm_authenticate($hash, $algorithm, $password) { function doveadm_authenticate($hash, $algorithm, $password) {
$descr = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); $descr = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
$pipes = array(); $pipes = array();
@ -76,7 +88,7 @@ function check_login($user, $pass) {
$stmt->execute(array(':user' => $user)); $stmt->execute(array(':user' => $user));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) { foreach ($rows as $row) {
if (doveadm_authenticate($row['password'], $GLOBALS['HASHING'], $pass) !== false) { if (verify_ssha256($row['password'], $pass) !== false) {
unset($_SESSION['ldelay']); unset($_SESSION['ldelay']);
return "admin"; return "admin";
} }
@ -88,7 +100,7 @@ function check_login($user, $pass) {
$stmt->execute(array(':user' => $user)); $stmt->execute(array(':user' => $user));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) { foreach ($rows as $row) {
if (doveadm_authenticate($row['password'], $GLOBALS['HASHING'], $pass) !== false) { if (doveadm_authenticate($row['password'], $pass) !== false) {
unset($_SESSION['ldelay']); unset($_SESSION['ldelay']);
return "domainadmin"; return "domainadmin";
} }
@ -99,7 +111,7 @@ function check_login($user, $pass) {
$stmt->execute(array(':user' => $user)); $stmt->execute(array(':user' => $user));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) { foreach ($rows as $row) {
if (doveadm_authenticate($row['password'], $GLOBALS['HASHING'], $pass) !== false) { if (doveadm_authenticate($row['password'], $pass) !== false) {
unset($_SESSION['ldelay']); unset($_SESSION['ldelay']);
return "user"; return "user";
} }

View File

@ -31,6 +31,4 @@ $DEFAULT_LANG = "en";
// See https://bootswatch.com/ // See https://bootswatch.com/
$DEFAULT_THEME = "lumen"; $DEFAULT_THEME = "lumen";
$HASHING = "SSHA256";
?> ?>

View File

@ -2,9 +2,11 @@
. mailcow.conf . mailcow.conf
if [[ -z $(which ss) ]]; then echo "Please install the ss util first."; exit 1; fi
for port in ${SMTP_PORT} ${SMTPS_PORT} ${SUBMISSION_PORT} ${IMAP_PORT} ${IMAPS_PORT} ${POP_PORT} ${POPS_PORT} ${SIEVE_PORT} 443; do for port in ${SMTP_PORT} ${SMTPS_PORT} ${SUBMISSION_PORT} ${IMAP_PORT} ${IMAPS_PORT} ${POP_PORT} ${POPS_PORT} ${SIEVE_PORT} 443; do
if [[ ! -z $(ss -tlnp "( sport = :$port )" 2> /dev/null | grep LISTEN | grep -vi docker) ]]; then if [[ ! -z $(ss -tlnp "( sport = :$port )" 2> /dev/null | grep LISTEN | grep -vi docker) ]]; then
echo "Port $port is in use by other process." echo "Port $port is in use by another process."
err=1 err=1
fi fi
done done