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

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

Материал из Solipse Wiki
Нет описания правки
 
(не показаны 24 промежуточные версии этого же участника)
Строка 2: Строка 2:
=== Install ===
=== Install ===
=== Configs ===
=== Configs ===
==== main.cf ====


/etc/postfix/main.cf
==== /etc/postfix/master.cf ====
 
# transport from Postfix to DSpam
dspam    unix  -      n      n      -      10      pipe
flags=Ru user=vmail argv=/usr/bin/dspam --deliver=innocent,spam --user $recipient -i -f $sender -- $recipient
# 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)
  smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
Строка 15: Строка 38:
  smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
  smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
  smtpd_use_tls=yes
  smtpd_use_tls=yes
smtpd_tls_wrappermode = yes
  smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
  smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_use_tls = yes
  smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
  smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_tls_security_level = may
smtp_tls_enforce_peername = no
   
   
  # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
  # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
Строка 76: Строка 103:
  smtpd_client_restrictions =
  smtpd_client_restrictions =
         permit_sasl_authenticated
         permit_sasl_authenticated
        reject_unknown_client_hostname
#      reject_unknown_client_hostname
         reject_rbl_client sbl.spamhaus.org
         reject_rbl_client sbl.spamhaus.org
         reject_rbl_client relays.ordb.org
         reject_rbl_client relays.ordb.org
Строка 83: Строка 110:
         reject_rbl_client sbl-xbl.spamhaus.org
         reject_rbl_client sbl-xbl.spamhaus.org
         reject_rbl_client zen.spamhaus.org
         reject_rbl_client zen.spamhaus.org
        check_client_access pcre:/etc/postfix/dspam_filter_access.prce
         permit
         permit
   
   
Строка 117: Строка 145:
  smtpd_delay_reject = yes
  smtpd_delay_reject = yes
  strict_rfc821_envelopes = yes
  strict_rfc821_envelopes = yes
message_size_limit = 204800000


==== /etc/postfix/checks/helo_checks.pcre ====
==== /etc/postfix/checks/helo_checks.pcre ====
Строка 123: Строка 152:
  /127\.0\.0\.1/                          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
  /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}/        REJECT We don't like dynamic addressess
==== /etc/postfix/dspam_filter_access.pcre ====
/./  FILTER dspam:dspam


==== Maps ====
==== Maps ====
Строка 171: Строка 204:


  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"
   
   
  # Куда будем сливать отфильтрованную почту (см. выше master.cf постфикса)
  # Return checked mail to queue ( look postfix master.cf)
  DeliveryHost        127.0.0.1
  DeliveryHost        127.0.0.1
  DeliveryPort        10025
  DeliveryPort        10025
Строка 185: Строка 218:
  Trust apache
  Trust apache
  Trust mail
  Trust mail
  Trust mailnull  
  Trust mailnull
  Trust smmsp
  Trust smmsp
  Trust daemon
  Trust daemon
Trust vmail
   
   
  TrainingMode teft
  TrainingMode teft
Строка 195: Строка 229:
  Tokenizer chain
  Tokenizer chain
  PValue bcr
  PValue bcr
  WebStats on
  WebStats on  
   
   
  # Что делать со спамом: добавлять заголовок в письмо с резулататом анализа (X-DSPAM-Result: Spam)
  # Spam action, add headers (X-DSPAM-Result: Spam)
  Preference "spamAction=tag"
  Preference "spamAction=tag"
  Preference "signatureLocation=headers"
  Preference "signatureLocation=headers"
Строка 210: Строка 244:
  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
Строка 237: Строка 271:
  ChangeUserOnParse full
  ChangeUserOnParse full
   
   
  # Параметры антивируса 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"
   
   
  # Путь к сокету
  # Socket path
  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 ===
Строка 261: Строка 297:
And to end of config
And to end of config
   
   
  # Путь к сокету
  # Socket path
  LocalSocket /var/run/clamav/clamd.sock
  LocalSocket /var/run/clamav/clamd.sock
  FixStaleSocket yes
  FixStaleSocket yes
   
   
  # Параметры TCP (см. выше dspam.conf)
  # TPC Port (Must by same dspam.conf)
  TCPSocket 3310
  TCPSocket 3310
  TCPAddr 127.0.0.1
  TCPAddr 127.0.0.1


== PostfixAdmin ==
=== /etc/postfixadmin/config.inc.php ===
$CONF['quota'] = 'NO'; -> $CONF['quota'] = 'YES';
$CONF['used_quotas'] = 'NO'; -> $CONF['used_quotas'] = 'YES';


$CONF['new_quota_table'] = 'NO'; -> $CONF['new_quota_table'] = 'YES';


== Links ==
== Links ==

Текущая версия от 12:52, 25 сентября 2013

Postfix

Install

Configs

/etc/postfix/master.cf

# transport from Postfix to DSpam
dspam     unix  -       n       n       -       10      pipe
	flags=Ru user=vmail argv=/usr/bin/dspam --deliver=innocent,spam --user $recipient -i -f $sender -- $recipient

# 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_wrappermode = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_use_tls = yes
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_tls_security_level = may
smtp_tls_enforce_peername = no

# 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
       check_client_access pcre:/etc/postfix/dspam_filter_access.prce
       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
message_size_limit = 204800000

/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

/etc/postfix/dspam_filter_access.pcre

/./   FILTER dspam:dspam

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"

# Return checked mail to queue ( look postfix 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
Trust vmail

TrainingMode teft
TestConditionalTraining on
Feature whitelist
Algorithm graham burton
Tokenizer chain
PValue bcr
WebStats on 

# Spam action, add headers (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"

# Socket path
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

# Socket path
LocalSocket /var/run/clamav/clamd.sock
FixStaleSocket yes

# TPC Port (Must by same dspam.conf)
TCPSocket 3310
TCPAddr 127.0.0.1

PostfixAdmin

/etc/postfixadmin/config.inc.php

$CONF['quota'] = 'NO'; -> $CONF['quota'] = 'YES';
$CONF['used_quotas'] = 'NO'; -> $CONF['used_quotas'] = 'YES';
$CONF['new_quota_table'] = 'NO'; -> $CONF['new_quota_table'] = 'YES';

Links