Squid
De BlaxWiki
Révision datée du 25 février 2013 à 14:26 par 217.174.199.129 (discussion) (→Exemple de configuration proxy simple)
Informations générales
Pour configurer un acces, il faut deja comprendre comment fonctionne squid. Squid va definir une source (le client), une destination (la ressource a acceder), et une regle pour lier
les deux. De base, toute les sources (definies ou non dans squid) n'ont aucun acces aux ressources (definies ou non dans squid). Pour ouvrir un acces, il faut en premier lieu creer
une source, creer une destination si celle-ci n'existe pas deja, puis une regle d'autorisation entre cette source et cette destination.
Si le proxy n'a jamais ete configure pour ce serveur, il faudra le configurer. Pour chaque client, si le reseau du client ne contient que du windows, créer une ligne (dans squid.conf)
acl <client>-1 src <reseau client>
puis ajouter ces 2 lignes
http_access allow CONNECT wuCONNECT <client>-1
http_access allow windowsupdate <client>-1
Si un seul serveur doit etre autorise ou si il s’agit d’un reseau prive avec plusieurs clients, remplacer <client>-1 par le nom du serveur.
Exemple de configuration proxy simple
Ici le proxy a pour role d'autoriser ou non l'accès à certaine url suivant l'ip source
# A ajuster suivant la ram cache_mem 512 MB # acl administrative acl manager proto cache_object acl localhost src 127.0.0.0/8 acl to_localhost dst 127.0.0.0/8 acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl CONNECT method CONNECT acl purge method PURGE ######################################################################################################################################### # Regles ben: on autorise ici le serveur 192.168.63.97/32 à faire des requetes sur le port 5030 de 217.109.5.9 & 212.234.218.100 # ######################################################################################################################################### acl test.ben src 192.168.63.97/32 # on acl ben_ports port 5030 acl ben_ip1_https dst 217.109.5.9/32 acl ben_ip2_https dst 212.234.218.100/32 acl ben_method method CONNECT http_access allow ben_method ben_ports ben_ip1_https test.ben http_access allow ben_method ben_ports ben_ip2_https test.ben ### Fin regles spec ben ### ############################################ # DEBUT: acls de destination ############################################ # acl windowsupdate dstdomain windowsupdate.microsoft.com acl windowsupdate dstdomain .update.microsoft.com acl windowsupdate dstdomain download.windowsupdate.com acl windowsupdate dstdomain redir.metaservices.microsoft.com acl windowsupdate dstdomain images.metaservices.microsoft.com acl windowsupdate dstdomain c.microsoft.com acl windowsupdate dstdomain www.download.windowsupdate.com acl windowsupdate dstdomain download.microsoft.com acl windowsupdate dstdomain support.microsoft.com acl windowsupdate dstdomain wustat.windows.com acl windowsupdate dstdomain crl.microsoft.com acl windowsupdate dstdomain au.download.windowsupdate.com acl windowsupdate dstdomain crl.verisign.com acl windowsupdate dstdomain mscrl.microsoft.com acl windowsupdate dstdomain www.microsoft.com acl windowsupdate dstdomain sls.microsoft.com acl windowsupdate dstdomain productactivation.one.microsoft.com acl windowsupdate dstdomain ntservicepack.microsoft.com acl windowsupdate dstdomain go.microsoft.com acl windowsupdate dstdomain ie9cvlist.ie.microsoft.com acl windowsupdate dstdomain activation.sls.microsoft.com acl wuCONNECT dstdomain www.update.microsoft.com acl wuCONNECT dstdomain test.update.microsoft.com acl wuCONNECT dstdomain sls.microsoft.com acl pecl dstdomain pecl.php.net acl pear dstdomain pear.php.net acl ubuntu dstdomain .ubuntu.com acl centos dstdomain .centos.org acl centos dstdomain .zend.com acl centos dstdomain mirror.ovh.net acl rhel dstdomain xmlrpc.rhn.redhat.com acl rhel dstdomain content-xmlrpc.rhn.redhat.com acl rhel dstdomain rhn.redhat.com acl scilnx dstdomain ftp1.scientificlinux.org acl windows dstdomain .microsoft.com acl perl dstdomain ftp.u-strasbg.fr acl perl dstdomain .perl.org acl perl dstdomain .cict.fr acl perl dstdomain .jussieu.fr acl perl dstdomain cpan.enstimac.fr acl sysinternals dstdomain .sysinternals.com acl package dstdomain package.infra.agarik.com acl package dstdomain package1.infra.agarik.com acl package dstdomain package2.infra.agarik.com acl agarik dstdomain .agarik.com acl python dstdomain .python.org acl vmware dstdomain .vmware.com acl php dstdomain .php.net acl debian dstdomain .debian.org acl zend dstdomain .zend.com acl postgres dstdomain .postgresql.org acl compellent dstdomain .compellent.com acl clamav dstdomain .clamav.net acl palo.alto.networks dstdomain .paloaltonetworks.com # ############################################ # FIN: acls de destination ############################################ ############################################ # DEBUT: acls de source ############################################ # # Uniquement pour le management acl web1.intra.agarik.com src 192.168.253.13/32 ## AGARIK # MEP acl reseau.install.mep.agarik.com src 10.253.6.0/24 # CA acl node01.c01.cloud.agarik.com src 192.168.10.10/32 acl node02.c01.cloud.agarik.com src 192.168.10.11/32 ############################################ # FIN: acls de source ############################################ ############################################ # DEBUT: Definition des autorisations ############################################ # Definition des autorisations d'acces via des paires acl reseau/acl destination # Pour squidclamav http_access allow localhost http_access allow purge localhost http_access deny purge url_rewrite_access deny localhost # Pour le manager http_access allow manager localhost http_access deny manager # On autorise que les ports 'classiques' de telechargement http/https/ftp http_access deny !Safe_ports http_access deny CONNECT !SSL_ports ########################################################### # Autorisations clients ########################################################### # Autorisations Agarik # ===================== # MEP (acces total) # Cette ligne permet au machine de l acl reseau.install.mep.agarik.com de sortir sur internet sur n'importe quel domaine, mais seulement sur les port 21,80,443 (comme définit pour l'acl Safe_ports) http_access allow reseau.install.mep.agarik.com # Agarik http_access allow CONNECT wuCONNECT bab.agarik.com http_access allow windowsupdate bab.agarik.com http_access allow perl bab.agarik.com ############################################ # FIN: Definition des autorisations ############################################ # on refuse tout icp_access deny all htcp_access deny all http_access deny all # Debut QOS delay_pools 1 delay_class 1 1 delay_access 1 allow all #De la QOS a été mise en place pour eviter de saturer la liaison vers internet des serveurs hotes. Un regle simple est de limitation de 5Mo/s est en place, cela laisse donc la moitie #de la liaison pour les autres VMs delay_parameters 1 5120000/5120000 # Fin QOS http_port 3128 hierarchy_stoplist cgi-bin ? #url_rewrite_program /opt/applis/squidclamav/bin/squidclamav -c /opt/applis/squidclamav/etc/squidclamav.conf #url_rewrite_children 15 icap_enable on icap_send_client_ip on icap_send_client_username on icap_client_username_encode off icap_client_username_header X-Authenticated-User icap_preview_enable on icap_preview_size 1024 icap_service service_req reqmod_precache bypass=off icap://localhost:1344/squidclamav adaptation_access service_req allow all icap_service service_resp respmod_precache bypass=off icap://localhost:1344/squidclamav adaptation_access service_resp allow all access_log syslog:local6.warning squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern (cgi-bin|\?) 0 0% 0 refresh_pattern . 0 20% 4320 icp_port 3130 coredump_dir /var/log/squid cache_dir ufs /opt/data/squid_cache 1024 16 256 cache_log /var/log/squid/cache.log
Script de vérification de la configuration
Ce script a pour but de vérifier principalement la coherence des objets. Il peut y avoir des warnings concernant des destinations non utilisées, ce qui est normal, les autres points doivent etre en OK.
#!/bin/bash
SQUID=/opt/applis/squid/etc/squid.conf
for source in `grep http_access $SQUID | sed -e "s/!//g" | awk '{print $3}'`
do
if [ `grep "${source}" $SQUID | grep -c acl ` -eq 0 ]; then
echo "ERROR : la source $source n'est pas declaree"
SRCERR="true"
fi
done
if [ "$SRCERR" != "true" ]; then echo "Sources Declarees : OK";fi
for destination in `grep http_access $SQUID | sed -e "s/!//g" | awk '{print $4}'`
do
if [ `grep "${destination}" $SQUID | grep -c acl` -eq 0 ]; then
echo "ERROR : la destination $destination n'est pas declaree"
DSTERR="true"
fi
done
if [ "$DSTERR" != "true" ]; then echo "Destinations Declarees : OK";fi
for source in `grep acl $SQUID | grep src | awk '{print $2}'`
do
if [ `grep "${source}" $SQUID | grep -c http_access ` -eq 0 ]; then
echo "WARNING : la source $source n'est pas utilise"
SRCWARN="true"
fi
done
if [ "$SRCWARN" != "true" ]; then echo "Sources utilisees : OK";fi
for destination in `grep acl $SQUID | grep dstdomain | awk '{print $2}' | sort |uniq`
do
if [ `grep "${destination}" $SQUID | grep -c http_access ` -eq 0 ]; then
echo "WARNING : la destination $destination n'est pas utilise"
DSTWARN="true"
fi
done
if [ "$DSTWARN" != "true" ]; then echo "Destinations utilisees : OK";fi