Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT →
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
utilisateurs:hypathie:tutos:proxy-transparent [16/10/2014 10:16] Hypathie [Configuration de squid comme proxy transparent] |
utilisateurs:hypathie:tutos:proxy-transparent [16/10/2014 13:30] Hypathie [Configuration de squid comme proxy transparent] |
||
---|---|---|---|
Ligne 92: | Ligne 92: | ||
eth1 (vers lan) : 192.168.1.1 | eth1 (vers lan) : 192.168.1.1 | ||
<code> | <code> | ||
+ | acl localnet src 192.168.1.0/24 | ||
httpd_accel_host virtual | httpd_accel_host virtual | ||
httpd_accel_port 80 | httpd_accel_port 80 | ||
Ligne 100: | Ligne 101: | ||
http_access allow lan | http_access allow lan | ||
</code> | </code> | ||
+ | > ''acl localnet src 192.168.1.0/24'' : le réseau qui doit avoir accès au serveur proxy | ||
+ | >''httpd_accel_host virtual'': Squid comme un accélérateur de http((Dans ce mode, Squid est capable de se substituer à un serveur http, il fonctionne alors en "reverse proxying". Il ne sert donc plus à partager "le monde" pour un réseau, mais à partager une machine (ou plusieurs) "au monde". Ainsi, les clients n'accéderons plus au serveur http, mais à Squid. Dans une configuration classique, Squid devra donc écouter sur le port 80 et avoir connaissance du serveur http qu'il remplace. )) | ||
+ | >''httpd_accel_port 80'': choix du port 80 comme port contrôlé par le proxy | ||
+ | >''httpd_accel_with_proxy on'': poser squid comme proxy local et comme accélérateur http | ||
+ | >''httpd_accel_uses_host_header on'': activer le nom d'hôte | ||
+ | >''acl lan src 192.168.1.1 192.168.2.0/24'': Liste de contrôle : le lan seulement utilise squid | ||
+ | >''http_access allow localhost'': accès à squid permis au localhost | ||
+ | >''http_access allow lan'': idem | ||
+ | |||
* Ce qui donne : | * Ce qui donne : | ||
Ligne 107: | Ligne 117: | ||
acl localhost src 127.0.0.1/32 # par défaut | acl localhost src 127.0.0.1/32 # par défaut | ||
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 # par défaut | acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 # par défaut | ||
- | acl localnet src 10.0.0.0/8 # RFC1918 possible internal network | + | acl localnet src 192.168.1.0/24 # RFC1918 possible internal network |
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network | acl localnet src 172.16.0.0/12 # RFC1918 possible internal network | ||
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network | acl localnet src 192.168.0.0/16 # RFC1918 possible internal network | ||
Ligne 164: | Ligne 174: | ||
coredump_dir /var/spool/squid | coredump_dir /var/spool/squid | ||
</code> | </code> | ||
- | ===== Installation ===== | ||
+ | ===Redémarrer squid=== | ||
+ | <code root>/etc/init.d/squid restart</code> | ||
+ | ===== configuration d'iptables (NAT) ===== | ||
+ | Nous n'avons pour l'instant que l'IP masquerade mis en place : | ||
+ | |||
+ | * On ajoute à iptables: | ||
+ | ''iptables -t nat -A PREROUTING -i interface_LAN -p tcp --dport 80 -j DNAT --to SQUID_SERVEUR:SQUID_PORT'' | ||
+ | <code root> | ||
+ | iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to 192.168.1.1:3128 | ||
+ | </code> | ||
+ | |||
+ | ''iptables -t nat -A PREROUTING -i interface_WEB -p tcp --dport 80 -j REDIRECT --to-port SQUID_PORT'' | ||
+ | <code root> | ||
+ | iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128 | ||
+ | </code> | ||
+ | |||
+ | * Ce qui donne : | ||
+ | <code root>iptables -L -t nat</code> | ||
+ | |||
+ | <code>Chain PREROUTING (policy ACCEPT) | ||
+ | target prot opt source destination | ||
+ | DNAT tcp -- anywhere anywhere tcp dpt:http to:192.168.1.1:3128 | ||
+ | REDIRECT tcp -- anywhere anywhere tcp dpt:http redir ports 3128 | ||
+ | |||
+ | Chain INPUT (policy ACCEPT) | ||
+ | target prot opt source destination | ||
+ | |||
+ | Chain OUTPUT (policy ACCEPT) | ||
+ | target prot opt source destination | ||
+ | |||
+ | Chain POSTROUTING (policy ACCEPT) | ||
+ | target prot opt source destination | ||
+ | MASQUERADE all -- anywhere anywhere</code> | ||
===== Utilisation ===== | ===== Utilisation ===== | ||