Squid mit Disk Daemon und Authentifizierung an ActiveDirectory Domain

Dies ist ein Howto zum Proxy Server Squid auf einem Linux Debian, mit Disk Daemon als Cache Verwaltung und Authentifizierung an einem Windows ActiveDirectory per ldap_auth.

Getestet auf Debian 4.0 und Squid 2.6.5 (Debian) sollte aber auf Debian 3.1 genauso laufen, dort könnten aber Pfade zu von Squid genutzten Programmen anders sein. Da epoll eingesetzt wird, ist ein 2.6er Kernel Vorraussetzung für diese Konfig. Die AD Seite war ein Windows 2003 Server mit Domain und Standartkonfiguration.

Die Konfigdatei ist auf folgende Einstellungen konfiguriert:

AD Server: 192.168.0.1
ActiveDirectory Domain: ads.local
LDAP Pfad: dc=ads,dc=local

Hostname: proxy.ads.local
IP-Netz: 192.168.0.0/24

Cache Größe: 3,5 GB
Cache Manager Passwort: hiermitcachepwersetzten

http_port = Proxyport
cache_dir = Was den Cache verwaltet, Pfad indem der Cache abgelegt wird, Größe des Cache
cache_replacement_policy = Wie der Cache in der Cache Dir verwaltet wird
memory_replacement_policy = Wie der Cache im Arbeitsspeicher verwaltet wird
auth_param = Authentifizierungsparamter, hier für ADS Auth
cachemgr_passwd = Cache Manager Passwort
error_directory = Template für Error Nachrichten

aptitude install squid

/etc/squid/squid.conf editieren

#	WELCOME TO SQUID 2
#	------------------
 
# NETWORK OPTIONS
# -----------------------------------------------------------------------------
 
http_port 3128
icp_port 3130
htcp_port 0
udp_incoming_address 0.0.0.0
udp_outgoing_address 255.255.255.255
  
 
# OPTIONS WHICH AFFECT THE CACHE SIZE
# -----------------------------------------------------------------------------
 
cache_mem 56 MB
cache_swap_low 88
cache_swap_high 93
maximum_object_size 5120 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 10 KB
 
ipcache_size 2048
ipcache_low 88
ipcache_high 93
fqdncache_size 2048
 
cache_replacement_policy heap GDSF
memory_replacement_policy heap GDSF
 
 
# LOGFILE PATHNAMES AND CACHE DIRECTORIES
# -----------------------------------------------------------------------------
 
cache_dir diskd /var/spool/squid 3500 25 256
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
emulate_httpd_log off
log_ip_on_direct on
mime_table /usr/share/squid/mime.conf
log_mime_hdrs off
pid_filename /var/run/squid.pid
debug_options ALL,1
log_fqdn off
client_netmask 255.255.255.255
 
 
# OPTIONS FOR EXTERNAL SUPPORT PROGRAMS
# -----------------------------------------------------------------------------
 
ftp_user nomail@proxy.com
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on
ftp_telnet_protocol on
 
dns_retransmit_interval 3 seconds
dns_timeout 40 seconds
hosts_file /etc/hosts
 
diskd_program /usr/lib/squid/diskd-daemon
unlinkd_program /usr/lib/squid/unlinkd
 
 
# OPTIONS FOR TUNING THE CACHE
# -----------------------------------------------------------------------------
 
wais_relay_port 0
request_header_max_size 20 KB
request_body_max_size 0 KB
 
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern .		0	20%	4320
 
quick_abort_min 16 KB
quick_abort_max 16 KB
quick_abort_pct 95
 
negative_ttl 5 minutes
positive_dns_ttl 4 hours
negative_dns_ttl 2 minutes
range_offset_limit 0 KB
 
 
# TIMEOUTS
# -----------------------------------------------------------------------------
 
forward_timeout 4 minutes
connect_timeout 1 minute
peer_connect_timeout 30 seconds
read_timeout 15 minutes
request_timeout 5 minutes
persistent_request_timeout 1 minute
client_lifetime 1 day
half_closed_clients on
pconn_timeout 120 seconds
ident_timeout 10 seconds
shutdown_lifetime 30 seconds
 
 
# ACCESS CONTROLS
# -----------------------------------------------------------------------------
 
# Authentifizierung
auth_param basic program /usr/lib/squid/ldap_auth -R 
  -b "dc=ads,dc=local" 
  -D "cn=Administrator,cn=users,dc=ads,dc=local" 
  -w "passwort"
  -f sAMAccountName=%s 
  -h 192.168.0.1
auth_param basic children 5
auth_param basic realm Proxyserver
auth_param basic credentialsttl 2 hours
 
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl login proxy_auth REQUIRED
acl local_dom dstdomain .ads.local
 
# Konfigurierte IP-Netze
acl localhost src 127.0.0.1/32
acl intern src 192.168.0.0/24
 
# Erlaubte Ports
acl Safe_ports port 21 80 443 8080
 
# Gesperrte Seiten
acl forbidden srcdomain .otto.de .youtube.de .ebay.de 
acl forbidden_rev dstdomain .otto.de .youtube.de .ebay.de
 
# Zugriff nur fuer localhost und intern
http_access deny !localhost !intern
 
# Zugriff nur auf Safe_ports
http_access deny !Safe_ports
 
# Zugriff auf gesperrte Seiten verbieten
http_access deny forbidden
http_access deny forbidden_rev
 
# Kein caching fuer lokale Domain
no_cache deny local_dom
 
# Managerzugriff nur ueber localhost
http_access allow manager localhost
http_access deny manager all
 
# TCP-Anfragen
reply_header_max_size 6 KB
reply_body_max_size 0 allow all
http_reply_access allow all
 
# Zugriff ueber Proxy ohne Authentifizierung fuer intern und localhost
http_access allow localhost
 
# Zugriff ueber Proxy nur Authentifiziert fuer public
http_access allow login
 
# Alles andere verbieten
http_access deny all
 
 
# ADMINISTRATIVE PARAMETERS
# -----------------------------------------------------------------------------
 
cache_mgr administrator@ads.local
cache_effective_user proxy
cache_effective_group proxy
visible_hostname proxy.ads.local
unique_hostname proxy.ads.local
hostname_aliases proxy.ads.local
 
 
# OPTIONS FOR THE CACHE REGISTRATION SERVICE
# -----------------------------------------------------------------------------
 
announce_period 0
announce_host tracker.ircache.net
announce_port 3131
 
 
# MISCELLANEOUS
# -----------------------------------------------------------------------------
 
dns_testnames www.google.de www.golem.de www.heise.de
logfile_rotate 0
tcp_recv_bufsize 0 bytes
memory_pools off
memory_pools_limit 5 MB
forwarded_for on
log_icp_queries on
icp_hit_stale off
minimum_direct_hops 4
minimum_direct_rtt 400
cachemgr_passwd hiermitcachepwersetzten all
store_avg_object_size 13 KB
store_objects_per_bucket 20
client_db on
netdb_low 900
netdb_high 1000
netdb_ping_period 5 minutes
query_icmp off
test_reachability off
buffered_logs off
reload_into_ims off
icon_directory /usr/share/squid/icons
short_icon_urls off
error_directory /usr/share/squid/errors/German
maximum_single_addr_tries 1
retry_on_error off

Wer die ACLs noch gerne erweitern möchte kann sich hier informieren wie es geht.

Optional können Delay Pools konfiguriert werden. Diese steuern die maximale Verbindungsgeschwindigkeit für jeden Client.

Hier die deutsche Beschreibung dazu.

# DELAY POOL PARAMETERS (all require DELAY_POOLS compilation option)
# -----------------------------------------------------------------------------
 
# 2 Delay Pools
delay_pools 2
 
delay_class 1 1
delay_class 2 2
 
# localhost: unbegrenzte Geschwindigkeit
delay_parameters 1 -1/-1
 
# intern: max. insgesamt = 2 MBit/s // max. pro user = 256 KBit/s
delay_parameters 2 262144/262144 32768/32768
 
# Verteilung auf die Delay-Pools
delay_access 1 allow localhost
delay_access 1 deny all
delay_access 2 allow intern
delay_access 2 deny all