This thread is my rubber ducky I hope you don’t mind too much 
So now I have
- traefik running as proxy
- a bunch of http containers that work fine
- a wildcard certificate
- a mailserver in a docker container: https://docker-mailserver.github.io
- I followed the setup instructions to the server and created users for both dovecot and postfix and I checked inside the container and they exist.
openssl s_client -connect ${DOMAINNAME}:993
And on port 465 answers with “connected” and some lengthy elaboration on the certificate which is the wildcard cert I got.
Snippet from the open ssl request because I am quite unable to understand it all but it mostly looks fine to me?
SSL handshake has read 5082 bytes and written 370 bytes
Verification: OK
---
New, TLSv1.3, Cipher is TLS_AES_128_GCM_SHA256
Server public key is 4096 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
Protocol : TLSv1.3
Docker Compose for Traefik
traefik :
image : traefik:v2.9
hostname: traefik
container_name : traefik
domainname: ${DOMAINNAME}
command:
- "--api.insecure=false"
- "--api.dashboard=true"
- "--accesslog=true"
- "--providers.docker=true"
- "--entryPoints.web.address=:80"
- "--entryPoints.websecure.address=:443"
- "--entryPoints.smtp.address=:25"
- "--entryPoints.smtp-ssl.address=:465"
- "--entryPoints.imap-ssl.address=:993"
- "--entryPoints.sieve.address=:4190"
- "--certificatesResolvers.myresolver.acme.email=XXXX"
- "--certificatesResolvers.myresolver.acme.storage=/etc/traefik/acme.json"
- "--certificatesResolvers.myresolver.acme.httpChallenge=true"
- "--certificatesResolvers.myresolver.acme.httpChallenge.entryPoint=web"
- "--certificatesresolvers.myresolver.acme.dnschallenge=true"
- "--certificatesresolvers.myresolver.acme.dnschallenge.provider=inwx"
environment:
- INWX_USERNAME_FILE=/run/secrets/inwx_username
- INWX_PASSWORD_FILE=/run/secrets/inwx_password
restart: unless-stopped
ports :
- 80:80
- 8080:8080
- 8443:8443
- 443:443
- 25:25
- 465:465
- 993:993
- 4190:4190
networks:
- frontend
labels:
# define some configs
- traefik.log.level=WARN
- traefik.providers.docker.network=frontend"
- traefik.api.dashboard=true"
- traefik.global.checkNewVersion=true"
- traefik.certificatesResolvers.myresolver.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory"
# redirect to https
- traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)
- traefik.http.routers.http_catchall.entrypoints=web
- traefik.http.routers.http_catchall.middlewares=https_redirect
- traefik.http.middlewares.https_redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https_redirect.redirectscheme.permanent=true
# define traefik dashboard router and service
- traefik.enable=true
- traefik.http.routers.traefik.rule=Host(`traefik.${DOMAINNAME}`)
- traefik.http.routers.traefik.entrypoints=websecure
- traefik.http.routers.traefik.tls.certResolver=myresolver
- traefik.http.routers.traefik.tls.domains[0].main=${DOMAINNAME}
- traefik.http.routers.traefik.tls.domains[0].sans=*.${DOMAINNAME}
- traefik.http.routers.traefik.middlewares=myauth
- traefik.http.routers.traefik.service=api@internal
- traefik.http.services.traefik.loadbalancer.server.port=8080
#basic auth
- traefik.http.middlewares.myauth.basicauth.usersfile=/etc/traefik/usersfile
- traefik.http.middlewares.myauth.basicauth.realm=Einmal mit Profis
- traefik.http.middlewares.myauth.basicauth.headerField=X-WebAuth-User
- traefik.http.middlewares.myauth.basicauth.removeheader=true
volumes :
- /var/run/docker.sock:/var/run/docker.sock:ro
- ${DOCKERDIR}/shared/htpasswd:/etc/traefik/usersfile
- ${DOCKERDIR}/shared/acme.json:/etc/traefik/acme.json
secrets:
- inwx_username
- inwx_password
Docker Compose for mailserver
mailserver:
image: docker.io/mailserver/docker-mailserver:latest
container_name: mailserver
restart: unless-stopped
depends_on:
- traefik
hostname: mail
domainname: ${DOMAINNAME}
environment:
- TZ=${TZ}
- LOG_LEVEL=debug
- ENABLE_FAIL2BAN=1
- SSL_TYPE=letsencrypt
- SSL_DOMAIN=${DOMAINNAME}
- PERMIT_DOCKER=host
- ONE_DIR=1
- ENABLE_POSTGREY=1
- ENABLE_CLAMAV=0
- ENABLE_SPAMASSASSIN=0
- SPOOF_PROTECTION=1
- POSTFIX_INET_PROTOCOLS=ipv4
- ENABLE_AMAVIS=0
- ENABLE_DNSBL=0
- ENABLE_MANAGESIEVE=1
- ENABLE_UPDATE_CHECK=0
- ACCOUNT_PROVISIONER=FILE
ports:
# only non default ports need mapping
- 10993:993 # IMAP4 (implicit TLS)
cap_add:
- NET_ADMIN
healthcheck:
test: "ss --listening --tcp | grep -P 'LISTEN.+:smtp' || exit 1"
timeout: 3s
retries: 0
labels :
- traefik.enable=true
- traefik.docker.network=frontend
#smtp router & service
- traefik.tcp.routers.smtp.rule=HostSNI(`*`)
- traefik.tcp.routers.smtp.entrypoints=smtp
- traefik.tcp.routers.smtp.service=smtp
- traefik.tcp.services.smtp.loadbalancer.server.port=25
- traefik.tcp.services.smtp.loadbalancer.proxyProtocol.version=1
#smtp ssl router & service
- traefik.tcp.routers.smtp-ssl.rule=HostSNI(`*`)
- traefik.tcp.routers.smtp-ssl.service=smtp-ssl
- traefik.tcp.routers.smtp-ssl.entrypoints=smtp-ssl
- traefik.tcp.routers.smtp-ssl.tls=true
- traefik.tcp.routers.smtp-ssl.tls.passthrough=false
- traefik.tcp.routers.smtp-ssl.tls.certresolver=myresolver
- traefik.tcp.services.smtp-ssl.loadbalancer.server.port=465
- traefik.tcp.services.smtp-ssl.loadbalancer.proxyProtocol.version=1
#imap ssl router & service
- traefik.tcp.routers.imap-ssl.rule=HostSNI(`*`)
- traefik.tcp.routers.imap-ssl.service=imap-ssl
- traefik.tcp.routers.imap-ssl.entrypoints=imap-ssl
- traefik.tcp.routers.imap-ssl.tls=true
- traefik.tcp.routers.imap-ssl.tls.passthrough=false
- traefik.tcp.routers.imap-ssl.tls.certresolver=myresolver
- traefik.tcp.services.imap-ssl.loadbalancer.server.port=10993
- traefik.tcp.services.imap-ssl.loadbalancer.proxyProtocol.version=2
#sieve router & service
- traefik.tcp.routers.sieve.rule=HostSNI(`*`)
- traefik.tcp.routers.sieve.entrypoints=sieve
- traefik.tcp.routers.sieve.service=sieve
- traefik.tcp.services.sieve.loadbalancer.server.port=4190
volumes:
- ${DOCKERDIR}/containers/mail/mail-data/:/var/mail/
- ${DOCKERDIR}/containers/mail/mail-state/:/var/mail-state/
- ${DOCKERDIR}/containers/mail/mail-logs/:/var/log/mail/
- ${DOCKERDIR}/containers/mail/config/:/tmp/docker-mailserver/
- ${DOCKERDIR}/shared/acme.json:/etc/letsencrypt/acme.json:ro
- /etc/localtime:/etc/localtime:ro
networks:
- frontend
(I am quite sure there is no sensitive data in the code I posted, as I put all passwords in docker secrets files and my domain is defined in the environment)
So here’s my (current) problem:
- I am using thunderbird to try to connect to the mailserver
- I have checked username and password multiple times-
- using Ports 465 / 993 with SSL/TLS
- I’ve tried all authentication methods
The result is always the same:
mailserver | Nov 28 17:57:10 mail postfix/smtps/smtpd[5104]: connect from [my current IP]
mailserver | Nov 28 17:57:20 mail postfix/smtps/smtpd[5104]: SSL_accept error from [my current IP]: lost connection
mailserver | Nov 28 17:57:20 mail dovecot: imap-login: Disconnected (no auth attempts in 10 secs): user=<>, rip= [my current IP], lip=172.26.0.2, TLS handshaking: Connection closed, session=<4kK+w4ruG8XZUV8m>
mailserver | Nov 28 17:57:20 mail postfix/smtps/smtpd[5104]: lost connection after CONNECT from [my current IP]
mailserver | Nov 28 17:57:20 mail postfix/smtps/smtpd[5104]: disconnect from [my current IP] commands=0/0
I think there are probably more SSL shenanigans going on… but I am dumbfounded for the moment.
Thanks for listening. If you have–just by chance–any ideas where my mistake lies… those would be very welcome. But I’ll just continue debugging this issue.
PS: mailservers are not my friends and this is not even the end of it as I have not even started on the customization that we need for our setup.
PPS: I turned off fail2ban, that was not it (this time)