Installieren
yum install squid
Squid konfigurieren
vim /etc/squid/squid.conf
Da die squid.conf sehr viele Einträge besitzt, empfehle ich eine Konfiguration über Webmin
- Cache aktivieren
- Netzwerk
Weitere Informationen im Netz:
Deutsch: http://www.squid-handbuch.de/hb/node28_ct.html oder http://www.squid-handbuch.de/hb/
Englisch: http://www.visolve.com/squid/squid24s1/contents.php
—-
Eine Anleitung zur Erstellung einer squid.conf
Für den Betrieb des Proxies muß ein Nameserver zugänglich sein. Dazu ist in /etc/rc.config in der Variable NAMESERVER die Adresse des Nameservers einzutragen. Sinnvollerweise der lokale Nameserver, also „127.0.0.1“. Ein Proxy-Cache, der einen externen Nameserver fragen muß, ist nicht ganz so optimal.
Konfiguration
vim /etc/squid/squid.conf
# Recommended minimum configuration: # acl manager proto cache_object acl localhost src 127.0.0.1/32 ::1 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1 # Example rule allowing access from your local networks. # Adapt to list your (internal) IP networks from where browsing # should be allowed acl localnet src 10.0.0.0/8 # 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 fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT acl QUERY urlpath_regex cgi-bin \? no_cache deny QUERY cache_mem 8 MB # # Recommended minimum Access Permission configuration: # # Only allow cachemgr access from localhost http_access allow manager localhost http_access deny manager # Deny requests to certain unsafe ports http_access deny !Safe_ports # Deny CONNECT to other than secure SSL ports http_access deny CONNECT !SSL_ports # We strongly recommend the following be uncommented to protect innocent # web applications running on the proxy server who think the only # one who can access services on "localhost" is a local user #http_access deny to_localhost # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # # Example rule allowing access from your local networks. # Adapt localnet in the ACL section to list your (internal) IP networks # from where browsing should be allowed http_access allow localnet http_access allow localhost # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 3128 # We recommend you to use at least the following line. hierarchy_stoplist cgi-bin ? # Uncomment and adjust the following to add a disk cache directory. cache_dir ufs /var/squid/cache 100 16 256 # Leave coredumps in the first cache dir coredump_dir /var/squid/coredump # Add any of your own refresh_pattern entries above these. refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320
Ordner erstellen und Berechtigungen anpassen
mkdir /var/squid/coredump mkdir /var/squid/cache chown -R squid:squid /etc/squid/ chmod -R 700 /var/squid/
Cache anlegen
squid -f /etc/squid/squid.conf -z
Testen, Starten und Stoppen
/usr/sbin/squid -z # testet die Konfiguration /etc/init.d/squid start # startet den Squid /etc/init.d/squid stop # Stopt den Squid
Weitere Informationen
Automatische Proxy Konfiguration
Die Konfiguration ist recht aufwendig. Man benötigt für eine Domäne einen lauffähigen Squid (OK, logisch), Apache, Bind und DHCPD. Die folgende Konfiguration läuft auf dem Server mit folgenden Diensten:
- isc-dhcpd-V3.0.2
- squid-2.5.10_6
- apache-2.0.54_2
- bind 8.3.7
Bei entsprechender Einstellung werden automatisch konfiguriert:
- Konquerer (KDE > 3.2)
- Firefox (> 1.03)
- Windows Explorer (> 5.5)
Das Script
Als erstes benötigt man ein Script, das man bei der Proxy-Konfiguration des Webbrowsers als 'Automatic proxy configuration URL' angeben kann. In kurzer From sieht dies folgendermaßen aus:
function FindProxyForURL(url,host) { if (isPlainHostName(host) || dnsDomainIs(host, ".DOMAIN")) { return "DIRECT"; } else { return "PROXY NAME.DOMAIN:PORT"; } }Anmerkung:, NAME.DOMAIN und PORT sind komplett durch eigene Bezeichnungen zu ersetzen. Wenn der Proxy z.B. unter foobar.my.dyndns.com auf Port 3128 erreichbar ist, steht in der Zeile return „PROXY foobar.my.dyndns.com:3128“; Dieses Script hat natürlich einige Mängel, man sollte Ausnahmen für Rechner und Webseiten angeben, aber für den ersten Test reicht das. Dieses Script speichert man als proxy.pac im Document Root des Webservers der eigenen Domäne ab. Dieses Script darf nur so eigenständig in dieser Datei stehen (und z.B. nicht in einer Webseite eingebaut werden) und muss laut Beispiel unter http://my.dyndns.com/wpad.dat erreichbar sein!
Eintrag im DNS
Der Webserver der unter http://DOMAIN erreichbar ist, sollte einen cname zu wpad.DOMAIN bekommen. Im Zonenfile steht also:
wpad IN CNAME DOMAIN.
Damit kann dann der Webserver konfiguriert werden:
<VirtualHost > ServerAdmin webmaster@DOMAIN DocumentRoot PATH ServerName DOMAIN ErrorLog /var/log/apache/DOMAIN.error_log TransferLog /var/log/apache/DOMAIN.access.log ServerAlias wpad.DOMAIN Redirect /proxy.pac <a class="linkification-ext" href="http:///DOMAIN/wpad.dat" title="Linkification: http:///DOMAIN/wpad.dat">http:///DOMAIN/wpad.dat</a> </VirtualHost>n die mime.types muss folgende Zeile eingefügt werden:
application/x-ns-proxy-autoconfig dat pac
Konfiguration des DHCP-Servers
In der dhcpd.conf vom isc-dhcpd steht folgendes:
option wpad-curl code 252 = text; shared-network NETZ { authoritative; subnet IP netmask 255.255.255.0 { [...] option wpad-curl "<a class="linkification-ext" href="http://DOMAIN/wpad.dat" title="Linkification: http://DOMAIN/wpad.dat">http://DOMAIN/wpad.dat</a>\n"; [...]Das wars dann schon. Nachdem die Dienste reloaded oder restarted wurden, sollte alles automatisch konfiguriert werden.