Installer et configurer SquidClamav sous Ubuntu 20.04 / 21.04

Dans cet article nous allons voir comment installer et configurer SquidClamav pour le serveur proxy Squid sous Ubuntu 20.04 / 21.04. Pour finir, nous verrons comment personnaliser les messages de SquidClamav.

Prérequis

Avoir une installation du serveur proxy Squid fonctionnelle et disposer des privilèges root.

Procédure

Installation des dépendances nécessaires :

# apt install gcc make curl c-icap libicapapi-dev libicapapi5 libssl-dev libtool-bin wget clamav-daemon

Téléchargement du module SquidClamav :

# wget https://sourceforge.net/projects/squidclamav/files/latest/download
# tar xvzf download
# cd squidclamav-7.1/

Configurer la compilation et réaliser l'installation :

# ./configure --with-c-icap="/usr/include/c_icap/"
# make
# make install
# libtool --finish /usr/lib/x86_64-linux-gnu/c_icap/

Modifier le fichier /etc/default/c-icap en remplaçant START=no par :

START=yes

Ajouter à la fin du fichier /etc/c-icap/c-icap.conf la ligne suivante :

Service squidclamav squidclamav.so

Modifier la configuration de  Squid pour utiliser le module SquidClamav en ajoutant le contenu suivant :

Fichier /etc/squid/squid.conf :

icap_enable on
adaptation_send_client_ip on
adaptation_send_username on
icap_client_username_header X-Authenticated-User
icap_service service_req reqmod_precache bypass=1 icap://127.0.0.1:1344/squidclamav
adaptation_access service_req allow all
icap_service service_resp respmod_precache bypass=1 icap://127.0.0.1:1344/squidclamav
adaptation_access service_resp allow all

Finalement, modifier le fichier suivant /etc/c-icap/squidclamav.conf

Passez la varibable SafeBrowsing à 0.
Commenter la ligne redirect http://proxy.domain.dom/cgi-bin/clwarn.cgi (en ajoutant # au début)

Redémarrer, vérifier et activer les services nécessaires :

# systemctl restart clamav-daemon
# systemctl status clamav-daemon
# systemctl restart c-icap
# systemctl status c-icap
# systemctl restart squid
# systemctl status squid
# systemctl enable clamav-daemon
# systemctl enable c-icap
# systemctl enable squid

Personnalisation

Dans la configuration du fichier /etc/c-icap/c-icap.conf, il y a deux directives importantes :

# Indique l'emplacement des modèles
TemplateDir /usr/share/c_icap/templates/

# Indique la langue des modèles
TemplateDefaultLanguage fr

Créer le répertoire /usr/share/c_icap/templates/squidclamav/fr si il n'existe pas (dans le cas ou vous souhaitez avoir les messages en français)

# mkdir /usr/share/c_icap/templates/squidclamav/
# ls -al /usr/share/c_icap/templates/squidclamav/
total 16
drwxr-xr-x 4 root root 4096 Mar 12 11:23 .
drwxr-xr-x 3 root root 4096 Mar 12 00:40 ..
drwxr-xr-x 2 root root 4096 Mar 12 11:19 en
drwxr-xr-x 2 root root 4096 Mar 12 11:48 fr

Le fichier utilisé pour afficher l'alerte en cas de détection d'un virus/malware est le suivant :

/usr/share/c_icap/templates/squidclamav/fr/MALWARE_FOUND

Voici un exemple d'un résultat possible :

Contenu du fichier /usr/share/c_icap/templates/squidclamav/fr/MALWARE_FOUND :

<html>
<head>
<title>Virus ou navigation non s&eacute;curis&eacute;e d&eacute;tect&eacute;e!</title>
</head>

<style type="text/css">
.visu {
border:1px solid #C0C0C0;
color:#FFFFFF;
position: relative;
min-width: 13em;
max-width: 52em;
margin: 4em auto;
border: 1px solid ThreeDShadow;
border-radius: 10px;
padding: 3em;
-moz-padding-start: 30px;
background-color: #8B0000;
}
.visu h2, .visu h3, .visu h4 {
font-size: 130%;
font-family: "times new roman", times, serif;
font-style: normal;
font-weight: bolder;

}
a:link, a:visited {
color: #FFFFFF;
text-decoration: underline;
}
</style>

<body>
<div class="visu">
<h1>SquidClamAv: Virus ou navigation non s&eacute;curis&eacute;e d&eacute;tect&eacute;e!</h1>

<p>
L'URL demand&eacute;e <b> %huo </b> contient un virus ou est r&eacute;pertori&eacute;e comme suspecte.<br><br>
Cette page ne peut pas &ecirc;tre affich&eacute;e ou le fichier ne peut pas &ecirc;tre t&eacute;l&eacute;charg&eacute;.
</p>
<p>
Type de virus ou programme malveillant / pishing: : <b> %mn </b>
</p>
<p>
Pour plus d'informations, contactez votre administrateur syst&egrave;me: XXXXXX@adminmalin.fr
</p>
<hr>
<p>
Ce message est g&eacute;n&eacute;r&eacute; par le service C-ICAP: <b> %iu </b>
</p>
</div>
</body>
</html>

 

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *