这是在已经运行Postfix的邮件服务器上添加rspamd的笔记。 服务器是Ubuntu20.04。
安装Redis
- 使用apt安装
# apt install redis
- 确认Redis正在运行
# systemctl status redis.service
确认active (running)
- 确认在端口6379上监听
# ss -ltn | grep 6379
LISTEN 0 511 127.0.0.1:6379 0.0.0.0:*
LISTEN 0 511 [::1]:6379 [::]:*
如果在0.0.0.0:6379或[::]:6379上监听,而没有通过iptables等进行防火墙设置,
可能会导致外部能够连接Redis,请注意。
安装Rspamd
- 使用apt安装
# apt install rspamd
- 通过向导进行设置
# rspamadm configwizard
____ _
| _ \ ___ _ __ __ _ _ __ ___ __| |
| |_) |/ __|| '_ \ / _` || '_ ` _ \ / _` |
| _ < \__ \| |_) || (_| || | | | | || (_| |
|_| \_\|___/| .__/ \__,_||_| |_| |_| \__,_|
|_|
欢迎使用配置工具
我们使用 /etc/rspamd/rspamd.conf 配置文件,结果写入 /etc/rspamd
启用的模块: hfilter, phishing, mime_types, dkim_signing, asn, settings, regexp, arc, bayes_expiry, trie, rbl, ip_score, metadata_exporter, elastic, fuzzy_check, mid, multimap, chartable, surbl, dkim, maillist, once_received, emails, dmarc, forged_recipients, milter_headers, whitelist, force_actions, spf
禁用的模块(显式):url_tags, url_reputation, spamtrap, dcc, mx_check, rspamd_update
禁用的模块(未配置):spamassassin, clickhouse, metric_exporter, dynamic_conf, clustering, reputation, fuzzy_collect, external_services, antivirus, maps_stats
禁用的模块(无Redis):greylist, url_redirector, replies, neural, ratelimit, history_redis
禁用的模块(实验性):
禁用的模块(失败):
您希望继续吗?[Y/n]:
设置WebUI和控制器工作者:
控制器密码未设置,您想设置一个吗?[Y/n]:
输入密码短语:
将加密密码设置为: $2$gs11ok3kj9wi59qohk79j3q8bi8zp1zt$krfgsjfz6inj978snusspgbxzthwj94y6nh69upe4d6ep5h39dpb
Redis服务器未设置:
如果您添加Redis服务器,以下模块将被启用:
* greylist
* url_redirector
* replies
* neural
* ratelimit
* history_redis
您希望设置Redis服务器吗?[Y/n]:
输入仅供读取的服务器,用`,`分隔 [默认: localhost]:
输入仅供写入的服务器,用`,`分隔 [默认: localhost]:
您是否为您的Redis设置了任何密码?[y/N]:
您是否为您的Redis设置了特定数据库?[y/N]:
您想设置dkim签名功能吗?[y/N]:
您有1个sqlite分类器
新令牌的过期时间 [100d]:
重置之前的数据吗?[y/N]:
您希望将其转换为Redis吗?[Y/n]:
转换垃圾邮件令牌
转换正常邮件令牌
为2个用户迁移了0个符号(BAYES_SPAM, BAYES_HAM)
将分类器从sqlite转换为redis
文件: /etc/rspamd/local.d/worker-controller.inc, 更改列表:
password => $********
文件: /etc/rspamd/local.d/classifier-bayes.conf, 更改列表:
backend => redis
new_schema => true
expire => 8640000
文件: /etc/rspamd/local.d/redis.conf, 更改列表:
write_servers => localhost
read_servers => localhost
应用更改吗?[Y/n]:
创建文件 /etc/rspamd/local.d/worker-controller.inc
创建文件 /etc/rspamd/local.d/classifier-bayes.conf
创建文件 /etc/rspamd/local.d/redis.conf
已应用3个更改,向导结束
*** 请重新加载Rspamd配置 ***
- 重新加载Rspamd
# systemctl reload rspamd
- Web界面
location /rspamd/ {
allow 192.168.0.0/16;
deny all;
proxy_pass http://127.0.0.1:11334/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
Postfix 的设置
# vi /etc/postfix/main.cf
smtpd_milters = inet:localhost:11332
milter_default_action = accept