Rspamd (DKIM) - How to setup dynamic path to support all domains/selectors?
#4575
-
|
I can swear this worked yesterday and today it won't at all, nothing is signed anymore: What happened is that yesterday at some point i forgot to comment the 1. 2. 3. lines, and restarted the container. Dkim signing stopped working after that, and even after I fixed the file. Now to get DKIM-signature again I have to add each domain manually inside a domain {} and cannot use $ variables at all. Now I would have to also edit this file each time I add a new domain. Why can't rspamd 3.12.1 use variables for the key path ? even $domain does not work. The help page at https://docs.rspamd.com/modules/dkim_signing/ clearly indicates that $domain in the private key file name should work |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
TL;DR: Add
Upstream docs explain what you needWhile DMS does provide the mail server image with services bundled and integrated with some conveniences like our That keeps maintenance/support simpler for us, since we can only spare to volunteer time unlike some others that have devs with financial support to work on the project 😅 When possible though, I try to push helpful information for common tasks onto our docs to save users that hassle. Looking at the official Rspamd docs: https://docs.rspamd.com/modules/dkim_signing
Which tells us that I have a tracking issue where I'd like to refactor Rspamd DKIM support in DMS to switch over to using the global At that linked tracking issue I do reference the Rspamd DKIM signing config docs, specifically calling out So at a minimum, you want these settings (I've added some contextual comments if helpful): I'm not too familiar with Rspamd config, but it looks like
So technically you could get away with only setting Adapting the reproduction name: example
services:
dms:
image: ghcr.io/docker-mailserver/docker-mailserver:${DMS_RELEASE:-15.1.0}
hostname: mail.example.test
environment:
ENABLE_RSPAMD: 1
ENABLE_OPENDKIM: 0
# NOTE: These ENV below are just to simplify the reproduction and aren't relevant to reproduction:
ENABLE_AMAVIS: 0
ENABLE_UPDATE_CHECK: 0
configs:
- source: dms-accounts
target: /tmp/docker-mailserver/postfix-accounts.cf
- source: rspamd-dkim
target: /tmp/docker-mailserver/rspamd/override.d/dkim_signing.conf
# The Docker Compose `configs` feature inlines file content into `compose.yaml` (convenient for reproductions)
# NOTE: `$` will be inferred as an ENV on the host to replace with a value if found,
# `$$` is required as an escape to opt-out of that feature when an actual `$` is expected in the file content.
configs:
dms-accounts:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8.
rspamd-dkim:
content: |
# Setting `path` will implicitly set `enabled = true;`:
path = "/tmp/docker-mailserver/rspamd/dkim/rsa-2048-$$selector-$$domain.private.txt";
# These are both implicit defaults configured by upstream at `/etc/rspamd/modules.d/dkim_signing.conf`
try_fallback = true;
selector = "dkim";
# For reproduction verification (also implicit by upstream default)
# Used to ensure DKIM signing is used when sending mail internally:
sign_local = true;Test that it's all working: # Start DMS:
$ docker compose up -d --force-recreate
# Wait about 20 sec (`grep rspamd <<< "$(ps -auxf)"` should then show rspamd child processes, signaling service is ready)
# Create DKIM keys (config already provided in advance via `configs.rspamd-dkim`):
$ docker compose exec dms setup config dkim selector dkim
# Send mail to self:
$ docker compose exec dms swaks --silent \
--server localhost --port 587 \
--auth PLAIN --auth-user [email protected] --auth-password secret \
--from [email protected] --to [email protected]
# Verify mail was receive with DKIM signature using expected selector:
$ docker compose exec dms grep -R dkim /var/mail/example.test/john.doe/new/
/var/mail/example.test/john.doe/new/1758603138.M252519P1420.mail.example.test,S=1322,W=1352: s=dkim; t=1758603138; |
Beta Was this translation helpful? Give feedback.
-
|
YEP |
Beta Was this translation helpful? Give feedback.
TL;DR: Add
try_fallback = true;to your config./etc/rspamd/modules.d/dkim_signing.conf. DMS could minimize the config generated for this module (I am not the maintainer of Rspamd support in DMS, so I wasn't aware of this default configs file until now).Upstream docs explain what you need
While DMS does provide the mail server image with services bundled and integrated with some conveniences like our
setupCLI commands and supported ENV config features, users are generally expected to become more familiar with upstream services config/doc…