Installation d’un proxy Squid
version OS: Centos 6.8
version Squid: 3.1
Pré requis
Voir l’article Préparation d’une machine Centos 6.x
1.Installation du paquet squid
$ sudo yum install squid
Éditer le fichier de conf squid et ajouter les modification en gras dans le texte
$ sudo vim /etc/squid/squid.conf
acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT acl lan src 192.168.3.0/24 <-- Autoriser le réseau local # # Recommended minimum Access Permission configuration: # # Only allow cachemgr access from localhost # from where browsing should be allowed http_access allow localnet http_access allow localhost http_access allow lan <-- Autoriser les aces lan # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 8080 <-- définir le port # Uncomment and adjust the following to add a disk cache directory. #cache_dir ufs /var/spool/squid 100 16 256 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320 request_header_access Referer deny all request_header_access X-Forwarded-For deny all request_header_access Via deny all request_header_access Cache-Control deny all visible_hostname proxy.domain.tld <-- forwarded_for off <-- pour ne pas afficher le proxy
Rendre le service automatique et le démarrer
$ sudo chkconfig squid on $ sudo /etc/rc.d/init.d/squid start
/!\ Penser a ouvrir le port 8080 dans Iptables
Modifier les paramètres du navigateur pour tester le proxy
2.Configuration des clients Linux
Éditer le fichier profile et ajouter en fin de ligne
$ sudo vim /etc/profile
MY_PROXY_URL="http://proxy.domain.local:8080/" HTTP_PROXY=$MY_PROXY_URL HTTPS_PROXY=$MY_PROXY_URL FTP_PROXY=$MY_PROXY_URL http_proxy=$MY_PROXY_URL https_proxy=$MY_PROXY_URL ftp_proxy=$MY_PROXY_URL export HTTP_PROXY HTTPS_PROXY FTP_PROXY http_proxy https_proxy ftp_proxy
Puis recharger le fichier
$ sudo source /etc/profile
Ajouter également en fin de ligne pour le fichier de conf yum
$ sudo vim /etc/yum.conf
proxy=http://proxy.domain.local:8080/
Et en fin de ligne pour le fichier de conf wget
# vim /etc/wgetrc
http_proxy = http://proxy.domain.local:8080/ https_proxy = http://proxy.domain.local:8080/ ftp_proxy = http://proxy.domain.local:8080/
3.Pour les navigateurs
Renseigner adresse IP ou nom d’hôte dans le paramètre réseau dans les navigateurs.
4.Utiliser une authentification
Il faut installer le paquet httpd-tools, nécessaire pour l’authentification http
$ sudo yum install httpd-tools
Éditer le fichier de conf squid et ajout de directive en gras dans le texte
$ sudo vim /etc/squid/squid.conf
acl CONNECT method CONNECT acl lan src 192.168.3.0/24 auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/.htpasswd auth_param basic children 5 auth_param basic realm Squid Basic Authentication <-- Type d'authentification auth_param basic credentialsttl 1 hours <-- Durée des credentials acl password proxy_auth REQUIRED http_access allow password # # Recommended minimum Access Permission configuration:
Création d’un utilisateur et son mot de passe
$ sudo htpasswd -c /etc/squid/.htpasswd nom_de_l'utilisateur
New password: ***** Re-type new password: *****
Puis redémarrer le service squid
$ sudo /etc/rc.d/init.d/squid restart
A l’ouverture d’un navigateur, renseigner les credentials précédemment crée.