18 oct 2010

SQUID Cache Manager + Lighttpd + FreeBSD

Debido a algunos errores de descriptores que aparecieron en el cache.log de SQUID, decidí no solo buscar el porque del error, sino también una manera de ver en tiempo real el funcionamiento de la cache. Ahí fue que recordé que había hablado en un post anterior del CacheMgr de Squid.

Por lo que me puse a configurarlo, pero usando Lihttpd en vez de Apache. Aquí van los pasos que realice:

Enable CacheManager Instalar Lighttpd – Configurar CGI – Activar Squid CacheMgr

1.1 Install lighttpd
1.1.1 cd /usr/ports/www/lighttpd
1.1.2 make install – not clean necesitaremos scripts desde los sources
1.2 Config lighttpd.conf
1.2.1 server.document-root = "/usr/local/www/data"
1.2.2 Create document-root dir
1.2.2.1 mkdir -p /usr/local/www/data
1.2.2.2 chown -R www:www /usr/local/www/data – Change owner
1.2.3 server.port = 8180
1.3 Create files that no exist
1.3.1 Create file server.errorlog = "/var/log/lighttpd.error.log"
1.3.1.1 touch /var/log/lighttpd.error.log
1.3.1.2 chown www:www /var/log/lighttpd.error.log
1.3.2 Create file accesslog.filename = "/var/log/lighttpd.access.log"
1.3.2.1 touch /var/log/lighttpd.access.log
1.3.2.2 chown www:www /var/log/lighttpd.access.log
1.4 Config lighttpd.conf for CGI support
1.4.1 Enabled lighttpd modules
1.4.1.1 server.modules = ( "mod_alias", "mod_access","mod_cgi","mod_accesslog" )
1.4.2 Add .cgi extension to exclude static content
1.4.2.1 static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi" )
1.4.3 Add alias to a cgi-bin dir
1.4.3.1 alias.url += ( "/cgi-bin" => "/usr/local/www/data/cgi-bin" )
$HTTP["url"] =~ "^/cgi-bin" { cgi.assign = ( "" => "" )
dir-listing.activate = "enable" }
1.4.4 Test file sintax
1.4.4.1 lighttpd -t -f /usr/local/etc/lighttpd.conf
1.5 Create boot script
1.5.1 Copy and Set vars for lighttpd.conf
1.5.1.1 cp /usr/ports/www/lighttpd/files/lighttpd.sh.in /etc/rc.d/lighttpd
1.5.1.2 chmod ug+x /etc/rc.d/lighttpd
1.5.1.3 Set : ${lighttpd_enable="YES"}
1.5.1.4 Set: : ${lighttpd_conf="/usr/local/etc/lighttpd.conf"}
1.5.1.5 Set : command=/usr/local/sbin/lighttpd
1.5.2 Enabled lighttpd in boot time
1.5.2.1 vi /etc/rc.conf add lighttpd_enable="YES"
1.6 Conf SQUID for Cachemgr.cgi
1.6.1 Check SQUID options
1.6.1.1 acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl webserver src 192.168.1.0/255.255.255.0
http_access allow manager localhost
http_access allow manager webserver
cache_mgr smith@localdomain (user for login into cachemgr)
cachemgr_passwd tu_password all (pass for login into cachemgr)
1.7 Conf /usr/local/etc/squid/cachemgr.conf
The access configuration file defining which Squid servers may be
managed via this cachemgr.cgi program.

1.7.1 Add squid.conf http_port into cachemgr.conf
1.8 Restart squid and lighttpd
1.8.1 /etc/rc.d/lighttpd restart; /etc/rc.d/squid restart

Luego se debería acceder desde el browser a la dirección del cache http://ip-cache:port_lighttpd/cgi-bin/cachemgr.cgi


 Luego con los datos subministrados anteriormente al squid.conf deberiamos logearnos.


References:

http://www.systmbx.com/lighttpd/configure-cgi-for-perl-programs-in-lighttpd-mod-cgi
 http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModCGI
 http://redmine.lighttpd.net/wiki/1/Docs:ModCGI
 http://wiki.squid-cache.org/SquidFaq/CacheManager#How_do_you_set_it_up.3F
 http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/configtuning-starting-services.html
 http://www.linuxparatodos.net/portal/staticpages/index.php?page=19-5-como-squid-cachemgr
 http://www.autosprint.es/opensuse/sec.squid.cachemgr.html