Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| email:mailscanner [2025/06/16 09:51] – willy | email:mailscanner [2026/04/13 14:52] (current) – [Web interface] willy | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== N) Mail Scanner | + | ====== N) Spam filtering |
| - | [[https://www.mailscanner.info|MailScanner]] is a tool that integrates your mail server (MTA = Postfix) with antivirus scanners and Spam Assassin. | + | [[https://github.com/ |
| - | MailScanner Gentoo latest package is obsolete, you must install manually. | ||
| - | Download generic 'Nix tarball from [[https:// | + | ===== Installation ===== |
| - | decompress | + | My VPS is pretty ancient |
| + | <file - rspamd> | ||
| + | mail-filter/ | ||
| + | </ | ||
| + | |||
| + | Now simply emerge it: | ||
| <code bash> | <code bash> | ||
| - | mkdir / | + | emerge |
| - | cd / | + | |
| - | wget ... | + | |
| - | tar xvf < | + | |
| - | cd MailScanner-xxx | + | |
| - | ./ | + | |
| - | ln -s /usr/ | + | |
| - | rc-update add msmilter-init default | + | |
| </ | </ | ||
| - | follow instructions and answer the various questions. | + | rspamd requires redis, but somehow it doesn' |
| - | MailScanner setup, see [[https:// | ||
| - | / | ||
| - | < | ||
| - | Run As User = postfix | ||
| - | Run As Group = postfix | ||
| - | Incoming Queue Dir = / | ||
| - | Outgoing Queue Dir = / | ||
| - | MTA = msmail | ||
| - | MSMail Queue Type = short | ||
| - | MSMail Delivery Method = QMQP | ||
| - | MSMail Socket Type = inet | ||
| - | MSMail Socket Dir = / | ||
| - | MSMail Relay Port = 628 | ||
| - | MSMail Relay Address = 127.0.0.1 | ||
| - | </ | ||
| - | / | + | ===== Configure rspamd ===== |
| - | < | + | |
| - | run_mailscanner=1 | + | |
| - | </ | + | |
| - | Postfix setup. | + | Create **/ |
| - | main.cf: | + | <file - actions.conf> |
| - | <code> | + | # Basic action thresholds |
| - | # MailScanner milter | + | reject = 15; |
| - | #smtpd_milters | + | add_header |
| - | # MailScanner milter may use QMQP for delivery | + | greylist = 4; # Temporary delay suspicious mail |
| - | qmqpd_authorized_clients | + | </ |
| - | </code> | + | |
| - | master.cf: | + | Configure redis **/ |
| - | < | + | <file redis.conf> |
| - | 628 | + | # Redis connection |
| + | servers | ||
| + | </file> | ||
| + | |||
| + | Setup a controller password for the web interface: | ||
| + | < | ||
| + | rspamadm pw | ||
| </ | </ | ||
| + | Create **/ | ||
| + | <file - worker-controller.inc> | ||
| + | # Replace with your generated password | ||
| + | password = " | ||
| + | </ | ||
| - | ====== Install MailWatch ====== | ||
| - | [[https:// | + | ===== Configure redis ===== |
| - | Follow docs [[https://docs.mailwatch.org/ | + | Setup redis at least in a basic and secure way **/etc/redis/redis.conf**: |
| + | <file - redis.conf> | ||
| + | # Bind only to localhost for security | ||
| + | bind 127.0.0.1 ::1 | ||
| + | # Set memory limit | ||
| + | maxmemory 500mb | ||
| + | maxmemory-policy volatile-ttl | ||
| + | </ | ||
| - | /etc/MailScanner/MailScanner.conf: | + | |
| + | ===== Configure postfix link ===== | ||
| + | |||
| + | Add milter integration to your Postfix configuration in **/etc/postfix/main.cf**: | ||
| < | < | ||
| - | Always Looked Up Last = & | + | # Enable Rspamd milter |
| - | Detailed Spam Report = yes | + | smtpd_milters |
| - | Quarantine Whole Message = yes | + | milter_default_action |
| - | Quarantine Whole Messages As Queue Files = no | + | milter_protocol |
| - | Include Scores In SpamAssassin Report = yes | + | |
| - | Quarantine User = root | + | |
| - | Quarantine Group = apache (this should be the same group as your web server) | + | |
| - | Quarantine Permissions | + | |
| </ | </ | ||
| - | Set queues permissions: | + | Configure Rspamd proxy worker in **/ |
| + | <file - worker-proxy.inc> | ||
| + | # Enable milter mode for Postfix integration | ||
| + | milter = yes; | ||
| + | timeout = 120s; | ||
| + | upstream " | ||
| + | default = yes; | ||
| + | self_scan = yes; # Scan messages directly | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Startup ===== | ||
| + | |||
| + | Ensure all the services are running and setup to start on boot: | ||
| <code bash> | <code bash> | ||
| - | usermod -a -G postfix | + | for i in rspamd redis postfix |
| - | chmod g+rx / | + | do |
| - | chmod g+rx / | + | rc-update add $i default |
| - | chgrp postfix | + | /etc/init.d/$i restart |
| - | chgrp postfix / | + | done |
| </ | </ | ||
| + | |||
| + | ===== Web interface ===== | ||
| + | |||
| + | By default rspamd web interface is exposed on **http:// | ||
| + | < | ||
| + | location /rspamd/ { | ||
| + | proxy_pass http:// | ||
| + | proxy_redirect | ||
| + | proxy_set_header | ||
| + | proxy_set_header | ||
| + | proxy_set_header | ||
| + | proxy_set_header | ||
| + | proxy_set_header | ||
| + | } | ||
| + | </ | ||