I can't find it documented anywhere and I also don't understand the logic behind this: why does PostfixAdmin need to read my TLS certificate private key to allow login or create users?
Postfix, Dovecot and IMAP clients work well with the default ownership and permissions settings of Let's Encrypt files and folders (probably because their master processes are run as root), however to login on PostfixAdmin or create an account I need to run, as root:
chown root:postfixadmin /etc/letsencrypt/live/example.org/privkey.pem
chown root:postfixadmin /etc/letsencrypt/live
chown root:postfixadmin /etc/letsencrypt/archive
chmod 640 /etc/letsencrypt/live/example.org/privkey.pem
chmod 750 /etc/letsencrypt/live
chmod 750 /etc/letsencrypt/archive
If settings are different from above, when logging in, the page will simply refresh, throwing this vague error in NginX error log:
2020/11/28 01:08:46 [error] 534
"PHP message: PostfixAdmin login failed (username: admin@example.org, ip_address: 127.0.0.1)"
while reading response header from upstream, client: 127.0.0.1, server: postfixadmin, request: "POST /login.php HTTP/1.0", upstream: "fastcgi://unix:/run/postfixadmin/postfixadmin.sock:", host: "example.org"
By creating a new admin from setup.php the error gets more useful:
2020/11/28 01:11:36 [error] 534
"PHP message: dovecotpw password encryption failed. STDERR output: doveconf: Fatal: Error in configuration file /etc/dovecot/dovecot.conf line 154: ssl_cert: Can't open file /etc/letsencrypt/live/example.org/fullchain.pem: Permission denied"
while reading response header from upstream, client: 127.0.0.1, server: postfixadmin, request: "POST /setup.php HTTP/1.0", upstream: "fastcgi://unix:/run/postfixadmin/postfixadmin.sock:", host: "example.org"
By changing ownership and permissions of only the directories /etc/letsencrypt/live and /etc/letsencrypt/archive, the error becomes:
2020/11/28 01:14:22 [error] 534
"PHP message: dovecotpw password encryption failed. STDERR output: doveconf: Fatal: Error in configuration file /etc/dovecot/dovecot.conf line 154: ssl_key: Can't open file /etc/letsencrypt/live/example.org/privkey.pem: Permission denied"
while reading response header from upstream, client: 127.0.0.1, server: postfixadmin, request: "POST /setup.php HTTP/1.0", upstream: "fastcgi://unix:/run/postfixadmin/postfixadmin.sock:", host: "example.org"