π‘ Docker Mailserver Setup: Postfix, Dovecot β Executive Summary
Technical architectural analysis, practical configuration manifests, and deployment instructions for Docker Mailserver Setup: Postfix, Dovecot.
Docker
Generate cf
bash
docker run --rm \
-e [email protected] \
-e MAIL_PASS=$pw \
-ti tvial/docker-mailserver:latest \
/bin/sh -c 'echo "$MAIL_USER|$(doveadm pw -s SHA512-CRYPT -u $MAIL_USER -p $MAIL_PASS)"' \
>> postfix-accounts.cf
K8s
helm install
bash
helm repo add docker-mailserver https://docker-mailserver.github.io/docker-mailserver-helm/
helm pull docker-mailserver/docker-mailserver --untar
# setting values.yaml
## tls setting (recomended cert-manager)
--set certificate = $TLS_SECRET
--set deployment.env.OVERRIDE_HOSTNAME = $MAIL_ADDRESS_HOST
--set deployment.env.TZ = "Asia/Seoul"
--set service.type = "NodePort"
--set service.nodePort.smtp = ""
--set persistence.mail-config.storageClass = $sc
--set persistence.mail-data.storageClass = $sc
--set persistence.mail-state.storageClass = $sc
--set persistence.mail-log.storageClass = $sc
# μ΅μ΄ κ³μ μμ± νμ
Access the operation pod and register an account
bash
k exec -it -n $ns deployments/docker-mailserver -- bash
setup email add $user@$OVERRIDE_HOSTNAME $pw
cat /tmp/docker-mailserver/postfix-accounts.cf
Inside setup.sh (/usr/local/bin/setup)
yaml
#email μΆκ°
setup email add $user@$OVERRIDE_HOSTNAME $pw
#dkim
setup config dkim
Exporter (failed)
bash
--set metrics.enabled = true
--set metrics.serviceMonitor.enabled = true
--set metrics.serviceMonitor.labels.release = $releaseLabel
# Image: blackflysolutions/postfix-exporter@sha256:7ed7c0534112aff5b44757ae84a206bf659171631edfc325c3c1638d78e74f73
# in container logic
/bin/postfix_exporter \
--postfix.showq_path /var/mail-state/spool-postfix/public/showq \
--postfix.logfile_path /var/log/mail/mail.log
>>>
2024/05/10 03:33:29 Reading log events from /var/log/mail/mail.log
2024/05/10 03:33:29 Listening on :9154
2024/05/10 03:33:29 FATAL -- failed to create Watcher
goroutine 34 [running]:
runtime/debug.Stack(0xc000418000, 0x21, 0x0)
/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
github.com/nxadm/tail/util.Fatal(0x9555f8, 0x18, 0x0, 0x0, 0x0)
/go/pkg/mod/github.com/nxadm/[email protected]/util/util.go:23 +0xc7
github.com/nxadm/tail/watch.(*InotifyTracker).run(0xc000412000)
/go/pkg/mod/github.com/nxadm/[email protected]/watch/inotify_tracker.go:220 +0x445
created by github.com/nxadm/tail/watch.glob..func1
/go/pkg/mod/github.com/nxadm/[email protected]/watch/inotify_tracker.go:55 +0x12f
<<<
Service Port
yaml
## Send Mail: smtp
- name: smtp
nodePort: 30025
port: 25
protocol: TCP
targetPort: smtp
## Send Mail: smtp (SSL)
- name: submissions
nodePort: 30465
port: 465
protocol: TCP
targetPort: submissions
## Send Mail: smtp (STARTTLS)
- name: submission
nodePort: 30587
port: 587
protocol: TCP
targetPort: submission
## SMTP SSL μ°κ²°μ λν νλ‘μ μλ²
- name: subs-proxy
nodePort: 30444
port: 10465
protocol: TCP
targetPort: subs-proxy
## SMTP STARTTLS μ°κ²°μ λν νλ‘μ μλ²
- name: sub-proxy
nodePort: 32074
port: 10587
protocol: TCP
targetPort: sub-proxy
## Receive: imap ν΄λΌμ΄μΈνΈ μμ ν¬νΈ
- name: imap
nodePort: 30143
port: 143
protocol: TCP
targetPort: imap
## Receive: imap ν΄λΌμ΄μΈνΈ SSL μμ ν¬νΈ (IMAPS)
- name: imaps
nodePort: 30993
port: 993
protocol: TCP
targetPort: imaps
## Receive: imap ν΄λΌμ΄μΈνΈ μμ νλ‘μ μλ²
- name: imap-proxy
nodePort: 30845
port: 10143
protocol: TCP
targetPort: imap-proxy
## Receive: imap ν΄λΌμ΄μΈνΈ SSL μμ νλ‘μ μλ² (IMAPS)
- name: imaps-proxy
nodePort: 32648
port: 10993
protocol: TCP
targetPort: imaps-proxy
## Rspamd: μ΄λ©μΌ μ€νΈ λ° λ°μ΄λ¬μ€λ₯Ό νν°λ§νλ λ° μ¬μ©λ μ μλ μ€νΈ νν°λ§ λ° μ΄λ©μΌ λΆμ λꡬ
- name: rspamd
nodePort: 30884
port: 11334
protocol: TCP
targetPort: rspamd
Additional Service
yaml
# SRS (Sender Rewriting Scheme)
# Description: μ΄ μλΉμ€λ λ³΄λΈ μ΄λ©μΌ μ£Όμλ₯Ό μ¬μμ±νμ¬ μ΄λ©μΌμ λ€μ μ λ¬ν λ λλ©μΈ μΈμ¦ λ¬Έμ λ₯Ό ν΄κ²°νκΈ° μν΄ μ¬μ©λ©λλ€. SRSλ SPF (Sender Policy Framework)μ κ΄λ ¨λ λ¬Έμ λ₯Ό ν΄κ²°νλ λ° λμμ΄ λ©λλ€.
deployment.env.ENABLE_SRS = 0
# OPENDKIM (Open DomainKeys Identified Mail)
# Description: μ΄ μλΉμ€λ μ΄λ©μΌ μλ²μμ λκ°λ μ΄λ©μΌμ λμ§νΈ μλͺ
μ μΆκ°νμ¬ μ΄λ©μΌμ μ λ’°μ±μ λμ΄λ λ° μ¬μ©λ©λλ€. μ΄λ₯Ό ν΅ν΄ μ΄λ©μΌ μμ μλ μ΄λ©μΌμ΄ μ€μ λ‘ λ³΄λΈ μ¬λμμ μλμ§ νμΈν μ μμ΅λλ€.
deployment.env.ENABLE_OPENDKIM = 0
# OPENDMARC (OpenDMARC)
# Description: μ΄ μλΉμ€λ μ΄λ©μΌ μμ νλ‘μΈμ€μμ DMARC (Domain-based Message Authentication, Reporting, and Conformance) μ μ±
μ μ μ©νμ¬ μ΄λ©μΌ λλ©μΈμ μμ‘°λ₯Ό λ°©μ§νκ³ μ΄λ©μΌ μ€νΈμ μ°¨λ¨νλ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_OPENDMARC = 0
# POLICYD_SPF (Policyd SPF)
# Description: μ΄ μλΉμ€λ SPF (Sender Policy Framework) μ μ±
μ μ μ©νμ¬ μ΄λ©μΌ μμ μμ λλ©μΈμμ μ¨ μ΄λ©μΌμ νμΈνλ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_POLICYD_SPF = 0
# POP3
# Description: POP3 (Post Office Protocol version 3)λ μ΄λ©μΌ ν΄λΌμ΄μΈνΈκ° μλ²μμ μ΄λ©μΌμ κ°μ Έμ€λ λ° μ¬μ©λλ νλ‘ν μ½μ
λλ€. μ΄ μλΉμ€λ POP3λ₯Ό μ¬μ©νμ¬ μ΄λ©μΌμ κ°μ Έμ€λ λ° νμν κΈ°λ₯μ μ 곡ν©λλ€.
deployment.env.ENABLE_POP3 =
# CLAMAV (Clam AntiVirus)
# Description: μ΄ μλΉμ€λ μ
μ± μ½λμ λ°μ΄λ¬μ€λ₯Ό νμ§νμ¬ μ΄λ©μΌ λ©μμ§λ₯Ό μ€μΊνλ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_CLAMAV = 0
# AMAVIS (Amavis-New)
# Description: μ΄ μλΉμ€λ μ΄λ©μΌ λ©μμ§λ₯Ό μ€μΊνμ¬ μ
μ± μ½λ, λ°μ΄λ¬μ€ λ° μ€νΈμ νμ§νκ³ μ²λ¦¬νλ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_AMAVIS = 0
# DNSBL (DNS-based Blackhole List)
# Description: μ΄ μλΉμ€λ μ€νΈ λλ μ
μ± μ΄λ©μΌμ νν°λ§νκΈ° μν΄ DNS κΈ°λ°μ λΈλν 리μ€νΈλ₯Ό μ¬μ©ν©λλ€.
deployment.env.ENABLE_DNSBL = 0
# FAIL2BAN
# Description: μ΄ μλΉμ€λ μλ²μ 보μμ κ°ννκΈ° μν΄ λ‘κ·Έλ₯Ό λͺ¨λν°λ§νκ³ μ§μ λ 쑰건μ λ°λΌ μλͺ»λ λ‘κ·ΈμΈ μλ λ±μ μ°¨λ¨νλ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_FAIL2BAN = 0
# MANAGESIEVE
# Description: MANAGESIEVEλ μ΄λ©μΌ ν΄λΌμ΄μΈνΈκ° μ΄λ©μΌ μλ²μ λν νν° λ° μ μ±
μ κ΄λ¦¬νκΈ° μν νλ‘ν μ½μ
λλ€.
deployment.env.ENABLE_MANAGESIEVE =
# SPAMASSASSIN
# Description: μ΄ μλΉμ€λ μ΄λ©μΌ λ©μμ§λ₯Ό μ€μΊνμ¬ μ€νΈμ νμ§νκ³ μ²λ¦¬νλ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_SPAMASSASSIN = 0
# SPAMASSASSIN_KAM
# Description: SPAMASSASSIN_KAMμ SPAMASSASSINκ³Ό ν¨κ» μ¬μ©λλ μΆκ° κΈ°λ₯μΌλ‘, μ€νΈμ νμ§νκ³ λΆλ₯νλ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_SPAMASSASSIN_KAM = 0
# FETCHMAIL
# Description: μ΄ μλΉμ€λ μΈλΆ μ΄λ©μΌ μλ²μμ μ΄λ©μΌμ κ°μ Έμ€λ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_FETCHMAIL = 0
# GETMAIL
# Description: GETMAILμ μΈλΆ μ΄λ©μΌ μλ²μμ μ΄λ©μΌμ κ°μ Έμ€λ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_GETMAIL = 0
# POSTGREY
# Description: μ΄ μλΉμ€λ μ΄λ©μΌ μλ²μ λν κ·Έλ μ΄λ¦¬μ€νΈλ₯Ό κ΄λ¦¬νμ¬ μ€νΈ λ©μμ§μ μ λ¬μ μ§μ°μν€λ λ° μ¬μ©λ©λλ€.
deployment.env.ENABLE_POSTGREY = 0
# SASLAUTHD
# Description: SASLAUTHDλ SMTP μΈμ¦μ μ²λ¦¬νλ λ° μ¬μ©λ©λλ€. (CRAM-MD5 λ±)
deployment.env.ENABLE_SASLAUTHD = 0




Leave a Reply