Run two rspamd instances

139 views
Skip to first unread message

Miles Chiang

unread,
Jan 5, 2017, 3:35:02 AM1/5/17
to rspamd
Hi all,

Is it possible to run two rspamd instances simultaneously with two different configurations ?
If yes, which options should I modify to avoid conflict ?

Now I am finding an alternative solution to replace MailScanner's spam and mcp (message content protection) detection functions.
I want to use rspamd because of its performance and the capability of reading spamassassin rules.
Since I already have some spamassassin rules for spam and mcp detections, and I want to keep the rules.
Postfix is my MTA server.

My idea is to run two rspamd (paired with rmilter) instances.
One instance loads spam rules and add spam header when hitting spam score threshold, and the other one loads mcp rules and add mcp header when hitting mcp score threshold.

Is my approach correct ? Or are there any better rspamd setups which can replace MailScanner's spam and mcp detection functions ?

Thank you in advance.

Best regards,
Miles



Andrew Lewis

unread,
Jan 5, 2017, 5:23:52 AM1/5/17
to rsp...@googlegroups.com
Hi Miles,

> Is it possible to run two rspamd instances simultaneously with two
> different configurations ?
> If yes, which options should I modify to avoid conflict ?

Sure, though that's not a supported configuration and may not be
necessary. You'd need to change listening ports on second instance and
set a couple of environment variables: CONFDIR, RUNDIR, DBDIR, LOGDIR.

> My idea is to run two rspamd (paired with rmilter) instances.
> One instance loads spam rules and add spam header when hitting spam score
> threshold, and the other one loads mcp rules and add mcp header when
> hitting mcp score threshold.
> Is my approach correct ? Or are there any better rspamd setups which can
> replace MailScanner's spam and mcp detection functions ?

I'm not clear on why you'd want to do that / what you want to
achieve/how. I'm not familiar with MailScanner. Maybe you can do what
you want with settings module:
https://rspamd.com/doc/configuration/settings.html - this is the usual
way to enable/disable certain checks.

Best,
-AL.

Miles Chiang

unread,
Jan 13, 2017, 11:29:38 AM1/13/17
to rspamd
Hi Andrew,

Thank you for your response.

The reason of running two rspamd (rmilter) is that I want to add two different headers by two different conditions.

For example, when a mail reaches the rspam score threshold, I want to add a header X-Spam: yes.
However, when a mail is detected by rspamd antivirus module, I want to add the other header X-Virus: yes.

In this situation, I have to run two rspamd (rmilter) to satisfy the needs, right ?
(Since rmilter only have one option "spam_header", I have to run two rmilter with two different settings of "spam_header")
Or do you have any better suggestions (such as a better setup or modifying code) for this situation ?

Best regards,
Miles


Andrew Lewis於 2017年1月5日星期四 UTC+8下午6時23分52秒寫道:

Andrew Lewis

unread,
Jan 13, 2017, 11:48:09 AM1/13/17
to rsp...@googlegroups.com
Hi Miles,

You could instruct Rmilter to add whichever desired headers using
Rspamd, for example by adding the following script to
/etc/rspamd/rspamd.local.lua

rspamd_config:register_symbol({
name = 'RMILTER_HEADERS',
type = 'postfilter',
priority = 10,
callback = function(task)
local add, del = {}, {}
local virus = task:get_symbol('CLAM_VIRUS')
if virus then
add['X-Virus'] = 'yes'
del['X-Virus'] = 1
end
local action = task:get_metric_action('default')
if action ~= 'no action' and action ~= 'greylist' then
add['X-Spam'] = 'yes'
del['X-Spam'] = 1
end
task:set_rmilter_reply({
add_headers = add,
remove_headers = del,
})
end
})

Best,
-AL.

Andrew Lewis

unread,
Jan 13, 2017, 12:30:14 PM1/13/17
to rsp...@googlegroups.com

... You'd want to always remove foreign headers mind you, so that's a
poor example:

6c6,10
< local add, del = {}, {}
---
> local add = {}
> local del = {
> ['X-Spam'] = 1,
> ['X-Virus'] = 1,
> }
10d13
< del['X-Virus'] = 1
15d17
< del['X-Spam'] = 1

Best,
-AL.
> --
> You received this message because you are subscribed to the Google
> Groups "rspamd" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to rspamd+un...@googlegroups.com.
> Visit this group at https://groups.google.com/group/rspamd.



Miles Chiang

unread,
Jan 13, 2017, 1:00:08 PM1/13/17
to rspamd
Hi Andrew,

I was always thinking to use options to solve it and forgot to try lua scripts.

Seems it can satisfy my needs.

Thank you for your response and it really helps me a lot.

Best regards,
Miles

Andrew Lewis於 2017年1月14日星期六 UTC+8上午1時30分14秒寫道:
Reply all
Reply to author
Forward
0 new messages