251 lines
8.6 KiB
Django/Jinja
251 lines
8.6 KiB
Django/Jinja
# {{ ansible_managed }}
|
||
# Fichier de configuration principal de postfix.
|
||
|
||
# +------------------+
|
||
# | Variables utiles |
|
||
# +------------------+
|
||
|
||
# Definition par securite (sinon il utilise gethostname)
|
||
myhostname = {{ ansible_hostname }}.crans.org
|
||
mydomain = crans.org
|
||
# Origine des mails
|
||
myorigin = crans.org
|
||
# Reseaux locaux
|
||
mynetworks = 127.0.0.0/8, [::1]/128
|
||
{% if postfix.primary or postfix.secondary %}
|
||
138.231.136.0/21, 185.230.79.0/24, 185.230.77.0/24, 185.230.76.0/24, 185.230.78.0/24, 10.53.0.0/19, 10.54.0.0/19, [2a0c:700:0:1::]/64, [2a0c:700:0:22::]/64, [2a0c:700:0:21::]/64, [2a0c:700:0:23::]/64, [2a0c:700:0:24::]/64, 10.231.136.0/24, [2a0c:700:0:2::]/64
|
||
{% else %}
|
||
10.231.136.0/24, [2a0c:700:0:2::]/64
|
||
{% endif %}
|
||
# Destinations acceptees
|
||
mydestination = {{ ansible_hostname }}, $myhostname, localhost, localhost.$mydomain
|
||
{% if postfix.primary or not postfix.secondary %}
|
||
$mydomain, crans.ens-cachan.fr, clubs.ens-cachan.fr, install-party.ens-cachan.fr, crans.fr, crans.eu
|
||
{% endif %}
|
||
# Domaine relaye par ce MX
|
||
relay_domains = $mydestination
|
||
{% if postfix.mailman %}
|
||
lists.$mydomain
|
||
{% endif %}
|
||
{% if postfix.secondary %}
|
||
$mydomain, crans.ens-cachan.fr, clubs.ens-cachan.fr, install-party.ens-cachan.fr, crans.fr, crans.eu
|
||
{% endif %}
|
||
{% if postfix.public %}
|
||
lists.$mydomain
|
||
{% endif %}
|
||
{% if postfix.mailman %}
|
||
relay_recipient_maps =
|
||
hash:/var/local/re2o-services/mail-server/generated/virtual
|
||
hash:/var/lib/mailman/data/virtual-mailman
|
||
mailman_destination_recipient_limit = 1
|
||
{% endif %}
|
||
# Etre notifie ou non de l'arrive de nouveaux mails
|
||
{% if postfix.primary or postfix.secondary %}
|
||
biff = no
|
||
{% else %}
|
||
biff = yes
|
||
{% endif %}
|
||
# Pour pouvoir tester sans tout casser, on active les soft bounces.
|
||
# Ca permet aux mails de ne pas etre bounces en cas d'erreur, mais
|
||
# a la place, de renvoyer une erreur non permanente. En production
|
||
# il faut enlever ca.
|
||
soft_bounce = no
|
||
|
||
smtpd_reject_unlisted_sender = yes
|
||
{% if not postfix.primary and not postfix.secondary %}
|
||
# On delivre dans des maildir
|
||
mail_spool_directory = /home/mail/
|
||
{% endif %}
|
||
# +--------+
|
||
# | Divers |
|
||
# +--------+
|
||
# Delais pour les warnings
|
||
delay_warning_time = 24h
|
||
# Esthetisme
|
||
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
|
||
# Par ou passer (notement pour la distrtibution des adresse
|
||
# locales par le serveur des adherents)
|
||
transport_maps = hash:/etc/postfix/transport
|
||
# Une infinite d'adresses mail par personne
|
||
recipient_delimiter = +
|
||
# +-----------------+
|
||
# | Bases d'adresse |
|
||
# +-----------------+
|
||
# Les fichiers d'alias (pour newaliases)
|
||
alias_database = hash:/var/local/re2o-services/mail-server/generated/aliases
|
||
alias_maps = $alias_database
|
||
# On prend aussi en compte les utilisateurs de /etc/passwd
|
||
local_recipient_maps = $alias_maps unix:passwd.byname
|
||
# Les anciennes ML @crans.org, @crans.ens-cachan.fr -> @lists.crans.org
|
||
virtual_alias_maps = hash:/var/local/re2o-services/mail-server/generated/virtual
|
||
|
||
# +-------------+
|
||
# | TLS et SASL |
|
||
# +-------------+
|
||
|
||
# TLS pour la reception
|
||
smtpd_use_tls=yes
|
||
smtpd_tls_security_level=may
|
||
smtpd_tls_cert_file=/etc/ssl/certs/smtp.pem
|
||
smtpd_tls_key_file=/etc/ssl/private/smtp.pem
|
||
smtpd_tls_loglevel=0
|
||
smtpd_tls_received_header=yes
|
||
|
||
# On utilise aussi TLS pour envoyer les mails
|
||
smtp_use_tls=yes
|
||
smtp_tls_security_level=may
|
||
smtp_tls_loglevel=1
|
||
smtp_tls_cert_file=
|
||
smtp_tls_key_file=
|
||
smtp_tls_CApath=/etc/ssl/certs/
|
||
|
||
|
||
# On cache les sessions TLS car elles sont couteuses.
|
||
smtpd_tls_session_cache_database=btree:/var/lib/postfix/smtpd_tls_session_cache
|
||
smtp_tls_session_cache_database=btree:/var/lib/postfix/smtp_tls_session_cache
|
||
|
||
tls_random_source=dev:/dev/urandom
|
||
|
||
# Auth que si tls pour eviter des pass en clair sur le reseau
|
||
smtpd_tls_auth_only=yes
|
||
# Authentification SASL pour relayer du mail
|
||
smtpd_sasl_auth_enable=yes
|
||
|
||
# +--------------------------+
|
||
# | Filtrages et limitations |
|
||
# +--------------------------+
|
||
|
||
{% if postfix.public %}
|
||
smtpd_helo_required = yes
|
||
smtpd_helo_restrictions = permit_mynetworks
|
||
reject_invalid_helo_hostname
|
||
reject_non_fqdn_helo_hostname
|
||
{% endif %}
|
||
## Limitation des messages envoyés par minute
|
||
# On n'ignore que les messages venant d'adresses "protégées"
|
||
smtpd_client_event_limit_exceptions = local_networks
|
||
10.231.136.0/24, [2a0c:700:0:2::]/64
|
||
# we remove the smtpd_access_maps, so that crans.org in the recipient_access does not capture subdomains
|
||
parent_domain_matches_subdomains = debug_peer_list,fast_flush_domains,mynetworks,permit_mx_backup_networks,qmqpd_authorized_clients,relay_domains
|
||
|
||
# On limite à 10 messages par minute
|
||
smtpd_client_message_rate_limit = 10
|
||
|
||
{% if postfix.public %}
|
||
smtpd_sender_login_maps = hash:/etc/postfix/sender_login_maps
|
||
{% endif %}
|
||
## Filtrage au MAIL FROM
|
||
smtpd_sender_restrictions = permit_mynetworks
|
||
{% if postfix.public %}
|
||
# Si pas authentifié pour un domaine de smtpd_sender_login_maps
|
||
# on dégage. Si authentifié, on envoit même si c'est du spoof
|
||
# interne.
|
||
reject_unauthenticated_sender_login_mismatch
|
||
{% endif %}
|
||
reject_non_fqdn_sender
|
||
reject_unknown_sender_domain
|
||
|
||
## Dit à postfix de jeter toute socket vers un serveur de policy après une
|
||
## utilisation. Il en recrée donc une nouvelle, ce qui permet d'éviter
|
||
## qu'un service de policy droppant silencieusement ses sockets ralentisse
|
||
## postfix. C'est un palliatif en attendant de corriger ratelimit/policy
|
||
smtpd_policy_service_request_limit = 1
|
||
## Filtrage au RCPT TO
|
||
smtpd_recipient_restrictions =
|
||
{% if postfix.primary %}
|
||
# Test avec policyd-rate-limit pour limiter le nombre de mails par utilisateur SASL
|
||
check_policy_service unix:ratelimit/policy
|
||
{% endif %}
|
||
# permet si le client est dans le reseau local
|
||
permit_mynetworks
|
||
# rejette les recipients sans nom de domaine totalement qualifie
|
||
reject_non_fqdn_recipient
|
||
{% if postfix.public %}
|
||
# permet si le client est authentifie
|
||
permit_sasl_authenticated
|
||
{% endif %}
|
||
# rejette les destinations non locales
|
||
reject_unauth_destination
|
||
{% if postfix.public %}
|
||
# accepte si on est sur un destinaire en @crans
|
||
check_recipient_access hash:/etc/postfix/recipient_access
|
||
# pour les @lists.crans.org, accepte si la greylist est d'accord
|
||
check_policy_service inet:127.0.0.1:2501
|
||
{% endif %}
|
||
# jette le reste
|
||
|
||
{% if postfix.primary %}
|
||
#smtpd_end_of_data_restrictions=check_policy_service inet:127.0.0.1:10031
|
||
{% endif %}
|
||
# Tailles maximales : 20Mo pour les msgs et 75 pour les mbox
|
||
message_size_limit = 20971520
|
||
mailbox_size_limit = 78643000
|
||
# Obligation de specifier le nom de domaine complet
|
||
{% if postfix.secondary %}
|
||
append_dot_mydomain = yes
|
||
{% else %}
|
||
append_dot_mydomain = no
|
||
{% endif %}
|
||
#Ajout de cyrus pour l'authentification SMTP
|
||
smtpd_sasl_type = cyrus
|
||
# Pieces jointes
|
||
mime_header_checks = regexp:/etc/postfix/mime_header_checks
|
||
# Transport slow
|
||
slow_destination_recipient_limit = 20
|
||
slow_destination_concurrency_limit = 2
|
||
{% if postfix.dkim %}
|
||
|
||
# Filtrage mail
|
||
milter_protocol = 2
|
||
milter_default_action = accept
|
||
smtpd_milters = inet:localhost:12301
|
||
non_smtpd_milters = inet:localhost:12301
|
||
|
||
{% endif %}
|
||
{% if postfix.titanic %}
|
||
relayhost = [soyouz.adm.crans.org]:25
|
||
{% endif %}
|
||
{% if postfix.primary or postfix.secondary %}
|
||
# PostScreen configuration
|
||
# Access List
|
||
postscreen_access_list = cidr:/etc/postfix/postscreen_access.cidr
|
||
## Tu es blacklisté ? VTFF
|
||
postscreen_blacklist_action = drop
|
||
|
||
# Bannière d'accueil multi valuée
|
||
postscreen_greet_banner = Bienvenue au crans, veuillez patienter quelques secondes.
|
||
## On droppe.
|
||
postscreen_greet_action = drop
|
||
# RBL, le retour
|
||
postscreen_dnsbl_sites =
|
||
zen.spamhaus.org*2
|
||
dnsbl.inps.de*2
|
||
b.barracudacentral.org*2
|
||
dnsbl-2.uceprotect.net*2
|
||
bl.spameatingmonkey.net
|
||
bl.spamcop.net
|
||
dnsbl.sorbs.net
|
||
psbl.surriel.com
|
||
bl.mailspike.net
|
||
swl.spamhaus.org*-2
|
||
list.dnswl.org=127.[0..255].[0..255].0*-1
|
||
list.dnswl.org=127.[0..255].[0..255].1*-2
|
||
list.dnswl.org=127.[0..255].[0..255].[2..255]*-3
|
||
|
||
# Score >= 4 ? Bye bye
|
||
postscreen_dnsbl_threshold = 4
|
||
postscreen_dnsbl_action = enforce
|
||
|
||
## Désactivé, pour éviter le fake greylisting de postscreen.
|
||
## Décommenter en cas de spam trop important.
|
||
## Filtre utilisé par postfix, mis en amont via postscreen
|
||
#postscreen_non_smtp_command_enable = yes
|
||
#postscreen_non_smtp_command_action = enforce
|
||
#
|
||
#postscreen_bare_newline_enable = yes
|
||
#postscreen_bare_newline_action = enforce
|
||
#
|
||
#postscreen_pipelining_enable = yes
|
||
#postscreen_pipelining_action = enforce
|
||
{% endif %}
|