.:The Tube:. The Tube

Transparenter Squid Proxy & SquidGuard Proxy Filter Installieren unter OpenBSD 3.6

Einführung

Dieses Crash Tutorial zeigt Dir wie man Squid und SquidGuard unter OpenBSD installert. Getestet wurde dieses Tutorial auf OpenBSD 3.6
Falls Du fragen oder anregungen hast kannst Du mir jederzeit ein Mail schreiben (tutorial@thetube.ch).

1. Was es dazu braucht :

2. Squid Installieren :

Squid Installieren ist der einfachste Teil vom ganzen Crash HowTo :
pkg_add squid-2.5.STABLE6-transparent

Jetzt muss die Datei /etc/squid/squid.conf modifiziert werden, hier miene Konfiguration :
http_port 127.0.0.1:3128
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
redirect_program /usr/local/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern .               0       20%     4320
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443 563     # https, snews
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
http_access deny to_localhost
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
acl our_networks src 192.168.1.0/24 192.168.0.0/24
http_access allow our_networks
http_access deny all
http_reply_access allow all
icp_access allow all
cache_mgr benny@thetube.ch
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
Voila, viele Parameter sind standartmässig. Nun wird squid zum erstan mal gestartet. Beim ersten starten von Squid müssen die Swap-Directorys eingerichtet werden (-z)
squid -z
Jetzt kann Squid gestartet werden :
squid
Jetzt hört squid auf der IP 127.0.0.1 (Localhost) und Port 3128. Wie bringen wir das LAN dazu das alle anfragen auf Port 80 kommen auf Squid umzuleiten? Wir konfigurieren den Paketfilter von OpenBSD (/etc/pf.conf) :
rdr pass on $int proto tcp to port www -> 127.0.0.1 port 3128
pass in on $int inet proto tcp from any to 127.0.0.1 port 3128 keep state
pass out on $ext inet proto tcp from any to any port www keep state
Nun mussen wir noch die Berechtigung von /dev/pf ändern :
chgrp squid /dev/pf
chmod g+rw /dev/pf
Paketfilter starten :
pfctl -r -F all -f /etc/pf.conf

3. BerkeleyDB Installieren :

Als erstes muss db-3.2.9.tar.gz von www.SleepyCat.com hertunter geladen werden. Es geht auch ohne die zwit patches aber es ist empfehlenswert diese Patches gleich zu installieren.
tar xzvf db-3.2.9.tar.gz 
cd db-3.2.9/dist
make all
su (auf root wechseln)
make install
Die BerkeleyDB wird ins Verzeichniss /usr/local/BerkeleyDB.3.2 installert.

4. squidGuard Installieren :

Auch hier muss squidGuard-1.2.0.tar.gz von www.squidGuard.org heruntergeladen werden.
mkdir /usr/local/squidGuard
cd /usr/local/squidGuard
mkdir db
chown squid.squid ../*
cd /var/log
mkdir squidGuard/logs
chown squid.squid /squidGuard/*
tar xzvf squidGuard-1.2.0.tar.gz 
cd squidGuard-1.2.0 

So, nun habe ich mir ein Script (makesquidGuard.sh) gemacht :
#!/bin/sh
./configure \
--with-sg-config=/var/squidGuard/conf/squidGuard.conf \
--with-sg-logdir=/var/squidGuard/logs \
--with-sg-dbhome=/var/squidGuard/db \
--with-db=/usr/local/BerkeleyDB.3.2
Ein chmod 700 aufs Script und mit
./makesquidGuard.sh 
starten
make all
su (auf root wechseln)
make install
cd /var/squidGuard/conf
Ladet die Blacklist runter (Aktuelle Version findet Ihr unter) :
ftp://ftp.teledanmark.no/pub/www/proxy/squidGuard/contrib/blacklists.tar.gz
Speichert die Blacklist unter : /usr/local/squidGuard/db und entpackt die Blacklist :
cd /usr/local/squidGuard/db
tar xzvf blacklists-20020504.tar.gz
Zur überprüfung wechselnt ins Verzeichniss : /usr/local/squidGuard/db/blacklists Nun solltet Ihr folgende Directorys sehen : ads , aggressive , audio-video , drugs , gambling , hacking , mail , porn , proxy , violence und warez

squidGuard.conf erstellen (Wer mehr über die Konfiguration von squidGuard wissen will soll sich die Doku von www.squidGuard.org anschauen) :
dbhome /var/squidGuard/db
logdir /var/squidGuard/logs
dest porn {
  domainlist blacklists/porn/domains
  urllist blacklists/porn/urls
  expressionlist blacklists/porn/expressions
  log porn.log
  redirect 
http://localhost:8080/cgi-bin/squidGuard.cgi?clientaddr=%a&clientname=%n&url=%u
}
dest proxy {
  domainlist blacklists/proxy/domains
  urllist blacklists/proxy/urls
  log proxy.log
  redirect 
http://localhost:8080/cgi-bin/squidGuard.cgi?clientaddr=%a&clientname=%n&url=%u
}
  src privileged {
  ip 192.168.1.100
}
acl {
  privileged {
    pass all
  }
  default {
    pass !porn !proxy  all
  }
}

Wichtig! Apache muss auf localhost (127.0.0.1) und Port 8080 horchen. Ich habe folgende änderungen in der httpd.conf vorgenommen:
Listen 127.0.0.1:8080

Referenzen

  1. OpenBSD Seite — Offizielle OpenBSD Seite
  2. UnixScout Seite — Jede Menge HowTo's!
  3. Squid Web Proxy Cache — Offizielle Squid Web Proxy Seite
  4. SquidGuard — Offizielle SquidGuard Seite
  5. Sleepycat Software — Seite der Berkeley DB Database
Zurück