postfix外掛廣告信過濾系統-Rspamd

Rspamd 讓我非常驚豔, 設定容易, 可以用來取代老牌amavisd-new套件

centos 7 系統簡易安裝如下:

  • 安裝套件
curl https://rspamd.com/rpm-stable/centos-7/rspamd.repo > /etc/yum.repos.d/rspamd.repo # For Centos-7
rpm --import https://rspamd.com/rpm-stable/gpg.key
yum -y update
yum -y install ca-certificates unbound redis rspamd  clamav clamav-devel clamav-scanner-systemd clamav-update clamav-data clamav-server clamav-server-systemd clamav-scanner
  • 修改/etc/redis.conf , 更改只接受localhost , 與port number
port 7379
bind 127.0.0.1 ::1
  • 更改後啟用redis
systemctl enable redis
systemctl start redis
  • 修改防毒設定 /etc/clamd.d/scan.conf

##########################################
LocalSocket /run/clamd.scan/clamd.sock
LocalSocketMode 666
FixStaleSocket yes
##########################################
  • 更改後啟用
systemctl enable clamav-freshclam
systemctl enable clamd\@scan
  • 下載這些我覺得應該要預設啟用的設定檔案
    下載完畢解開, 將 local.d 與 override.d 目錄裏檔案, 複製到 /etc/rspamd/local.d ,/etc/rspamd/override.d 相應目錄中
https://kafeiou.pw/wp-content/uploads/2022/02/rspamd.zip
  • 啟用rspamd
usermod -aG clamscan _rspamd
usermod -aG virusgroup _rspamd
systemctl enable rspamd
chown -R _rspamd:_rspamd /etc/rspamd/override.d
systemctl start rspamd
  • 修改 /etc/postfix/main.cf
smtpd_milters = inet:127.0.0.1:11332
non_smtpd_milters = $smtpd_milters
milter_default_action = accept
  • 更改後重開postfix
postfix reload
  • 使用http 反向代理導到 http://localhost:11332 , 這樣就能使用網頁方式看狀況了
<VirtualHost *:443>
  ServerName mail.test.com

  ErrorLog /var/log/httpd/ssl_error_log
  TransferLog /var/log/httpd/ssl_access_log

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/mail.test.com/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/mail.test.com/privkey.pem
  SSLCACertificateFile /etc/letsencrypt//live/mail.test.com/fullchain.pem

  SSLProxyEngine On
  ProxyRequests Off
  ProxyPreserveHost On
  RequestHeader set X-Forwarded-Proto "https"
  ProxyPass /rspamd/ http://localhost:11334/
  ProxyPassReverse /rspamd/ http://localhost:11334/
  <Location />
    Order allow,deny
    Allow from all
  </Location>
  <Location /rspamd>
    Require all granted
  </Location>
  RewriteEngine On
  RewriteRule ^/rspamd$ /rspamd/ [R,L]
  RewriteRule ^/rspamd/(.*) http://127.0.0.1:11334/$1 [P]
</VirtualHost>

  • 先前步驟下載的檔案有預設密碼, 網頁登入預設密碼是kafeiou.pw
    可使用 以下指令修改
rspamadm pw

發表迴響