Перейти к содержанию

Postfix with DSPAM: различия между версиями

Материал из Solipse Wiki
Строка 193: Строка 193:


  Home /var/spool/dspam
  Home /var/spool/dspam
  StorageDriver /usr/lib64/dspam/libmysql_drv.so
  StorageDriver /usr/lib/x86_64-linux-gnu/dspam/libmysql_drv.so
  TrustedDeliveryAgent "/usr/bin/procmail"
  TrustedDeliveryAgent "/usr/bin/procmail"
   
   
Строка 207: Строка 207:
  Trust apache
  Trust apache
  Trust mail
  Trust mail
  Trust mailnull  
  Trust mailnull
  Trust smmsp
  Trust smmsp
  Trust daemon
  Trust daemon
Строка 217: Строка 217:
  Tokenizer chain
  Tokenizer chain
  PValue bcr
  PValue bcr
  WebStats on
  WebStats on  
 
  # Что делать со спамом: добавлять заголовок в письмо с резулататом анализа (X-DSPAM-Result: Spam)
  # Что делать со спамом: добавлять заголовок в письмо с резулататом анализа (X-DSPAM-Result: Spam)
  Preference "spamAction=tag"
  Preference "spamAction=tag"
Строка 232: Строка 232:
  AllowOverride showFactors
  AllowOverride showFactors
  AllowOverride optIn optOut
  AllowOverride optIn optOut
  AllowOverride whitelistThreshold
  AllowOverride whitelistThreshold  
   
   
  HashRecMax 98317
  HashRecMax             98317
  HashAutoExtend on
  HashAutoExtend         on
  HashMaxExtents 0
  HashMaxExtents         0
  HashExtentSize 49157
  HashExtentSize         49157
  HashPctIncrease 10
  HashPctIncrease 10
  HashMaxSeek 10
  HashMaxSeek             10
  HashConnectionCache 10
  HashConnectionCache     10
  Notifications off
  Notifications   off
   
   
  PurgeSignature off # Specified in purge.sql
  PurgeSignature off # Specified in purge.sql
  PurgeNeutral  90
  PurgeNeutral  90
  PurgeUnused    off # Specified in purge.sql
  PurgeUnused    off # Specified in purge.sql
Строка 260: Строка 260:
   
   
  # Параметры антивируса ClamAV
  # Параметры антивируса ClamAV
  ClamAVPort 3310
  ClamAVPort     3310
  ClamAVHost 127.0.0.1
  ClamAVHost     127.0.0.1
  ClamAVResponse  accept
  ClamAVResponse  accept
   
   
  ServerPID              /var/run/dspam/dspam.pid
  ServerPID              /var/run/dspam/dspam.pid
  ServerMode              auto
  ServerMode              auto
  ServerParameters "--deliver=innocent"
  ServerParameters       "--deliver=innocent"
  ServerIdent "localhost.localdomain"
  ServerIdent             "localhost.localdomain"
  ServerDomainSocketPath  "/var/run/dspam/dspam.sock"
  ServerDomainSocketPath  "/var/run/dspam/dspam.sock"
   
   
  # Путь к сокету
  # Путь к сокету
  ClientHost "/var/run/dspam/dspam.sock"
  ClientHost     "/var/run/dspam/dspam.sock"
   
   
  ProcessorURLContext on
  ProcessorURLContext on
  ProcessorBias on
  ProcessorBias on
  StripRcptDomain off
  StripRcptDomain off
Include /etc/dspam/dspam.d/


=== ClamAV ===
=== ClamAV ===

Версия от 11:37, 28 мая 2012

Postfix

Install

Configs

/etc/postfix/master.cf

# transport from Postfix to DSpam
dspam     unix  -       -       n       -       10      lmtp

# transport from DSpam to Postfix
127.0.0.1:10025 inet    n       -       n       -       -       smtpd
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o receive_override_options=no_unknown_recipient_checks,no_address_mappings

# Dovecot LDA
dovecot   unix  -       n       n       -       -       pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}

# policyd-spf
spf       unix  -       n       n       -       0       spawn
user=nobody argv=/opt/pyspf/policyd-spf /opt/pyspf/policyd-spf.conf

/etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = mx.mailhost.ru
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $myhostname
mydestination = $myhostname
relayhost =
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
virtual_mailbox_domains = proxy:mysql:/etc/postfix/virtual-mailbox-domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/virtual-mailbox-maps.cf
virtual_alias_maps = proxy:mysql:/etc/postfix/virtual-alias-maps.cf
smtpd_sender_login_maps = proxy:mysql:/etc/postfix/virtual-login-maps.cf

proxy_read_maps =
 $local_recipient_maps
 $mydestination
 $virtual_alias_maps
 $virtual_alias_domains
 $virtual_mailbox_maps
 $virtual_mailbox_domains
 $relay_recipient_maps
 $relay_domains
 $canonical_maps
 $sender_canonical_maps
 $recipient_canonical_maps
 $relocated_maps
 $transport_maps
 $mynetworks
 $sender_bcc_maps
 $recipient_bcc_maps
 $smtp_generic_maps
 $lmtp_generic_maps
 $smtpd_sender_login_maps

virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

smtpd_recipient_restrictions =
       permit_sasl_authenticated
       reject_unlisted_recipient
       reject_non_fqdn_sender
       reject_unknown_recipient_domain
       reject_unauth_pipelining
       reject_non_fqdn_recipient
       reject_unauth_destination
       permit

smtpd_client_restrictions =
       permit_sasl_authenticated
       reject_unknown_client_hostname
       reject_rbl_client sbl.spamhaus.org
       reject_rbl_client relays.ordb.org
       reject_rbl_client cbl.abuseat.org
       reject_rbl_client bl.spamcop.net
       reject_rbl_client sbl-xbl.spamhaus.org
       reject_rbl_client zen.spamhaus.org
       permit

smtpd_helo_required = yes
smtpd_helo_restrictions =
       permit_mynetworks
       permit_sasl_authenticated
       check_helo_access pcre:/etc/postfix/checks/helo_checks.pcre
       reject_non_fqdn_helo_hostname
       reject_unknown_helo_hostname
       reject_invalid_helo_hostname
       permit

smtpd_sender_restrictions =
       reject_non_fqdn_sender
       reject_unknown_sender_domain
#       reject_sender_login_mismatch
       permit_sasl_authenticated
       permit

smtpd_data_restrictions =
       permit_mynetworks
       permit_sasl_authenticated
       reject_unauth_pipelining
       permit

smtpd_end_of_data_restrictions =
       permit_mynetworks
       permit_sasl_authenticated
       reject_multi_recipient_bounce
       permit

smtpd_reject_unlisted_sender = yes
smtpd_delay_reject = yes
strict_rfc821_envelopes = yes

/etc/postfix/checks/helo_checks.pcre

/mx\.mailhost\.ru/                       REJECT You are not me
/127\.0\.0\.1/                           REJECT You are not me
/\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}/        REJECT We don't like dynamic addressess

Maps

/etc/postfix/virtual-mailbox-domains.cf
user = postfixadmin
password = password
hosts = 127.0.0.1
dbname = postfixadmin
query = select `domain` from `domain` where `domain` = '%s' and `active` = '1'
/etc/postfix/virtual-mailbox-maps.cf
user = postfixadmin
password = password
hosts = 127.0.0.1
dbname = postfixadmin
query = select `maildir` from `mailbox` where `username` = '%s' and `active` = '1'
/etc/postfix/virtual-alias-maps.cf
user = postfixadmin
password = password
hosts = 127.0.0.1
dbname = postfixadmin
query = select `goto` from `alias` where `address` = '%s' and `active` = '1'
/etc/postfix/virtual-login-maps.cf
user = postfixadmin
password = password
hosts = 127.0.0.1
dbname = postfixadmin
query = select `username` from `mailbox` where `username` = '%s' and `active` = '1'

Dspam

Install

apt-get install clamav dpsam dovecot-antispam

Configs

/etc/default/dspam

Change START=no to START=yes

/etc/dspam/dspam.conf

Home /var/spool/dspam
StorageDriver /usr/lib/x86_64-linux-gnu/dspam/libmysql_drv.so
TrustedDeliveryAgent "/usr/bin/procmail"

# Куда будем сливать отфильтрованную почту (см. выше master.cf постфикса)
DeliveryHost        127.0.0.1
DeliveryPort        10025
DeliveryIdent       localhost
DeliveryProto       SMTP
OnFail error

Trust root
Trust dspam
Trust apache
Trust mail
Trust mailnull
Trust smmsp
Trust daemon

TrainingMode teft
TestConditionalTraining on
Feature whitelist
Algorithm graham burton
Tokenizer chain
PValue bcr
WebStats on 
# Что делать со спамом: добавлять заголовок в письмо с резулататом анализа (X-DSPAM-Result: Spam)
Preference "spamAction=tag"
Preference "signatureLocation=headers"
Preference "showFactors=off"

AllowOverride trainingMode
AllowOverride spamAction spamSubject
AllowOverride statisticalSedation
AllowOverride enableBNR
AllowOverride enableWhitelist
AllowOverride signatureLocation
AllowOverride showFactors
AllowOverride optIn optOut
AllowOverride whitelistThreshold 

HashRecMax              98317
HashAutoExtend          on
HashMaxExtents          0
HashExtentSize          49157
HashPctIncrease 10
HashMaxSeek             10
HashConnectionCache     10
Notifications   off

PurgeSignature  off # Specified in purge.sql
PurgeNeutral   90
PurgeUnused    off # Specified in purge.sql
PurgeHapaxes   off # Specified in purge.sql
PurgeHits1S    off # Specified in purge.sql
PurgeHits1I    off # Specified in purge.sql

LocalMX 127.0.0.1
SystemLog on
UserLog   on
Opt out
TrackSources spam nonspam
ParseToHeaders on
ChangeModeOnParse on
ChangeUserOnParse full

# Параметры антивируса ClamAV
ClamAVPort      3310
ClamAVHost      127.0.0.1
ClamAVResponse  accept

ServerPID               /var/run/dspam/dspam.pid
ServerMode              auto
ServerParameters        "--deliver=innocent"
ServerIdent             "localhost.localdomain"
ServerDomainSocketPath  "/var/run/dspam/dspam.sock"

# Путь к сокету
ClientHost      "/var/run/dspam/dspam.sock"

ProcessorURLContext on
ProcessorBias on
StripRcptDomain off

Include /etc/dspam/dspam.d/

ClamAV

/etc/clamav/clamd.conf

And to end of config

# Путь к сокету
LocalSocket /var/run/clamav/clamd.sock
FixStaleSocket yes

# Параметры TCP (см. выше dspam.conf)
TCPSocket 3310
TCPAddr 127.0.0.1


Links