notas:squid
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Próxima revisión | Revisión previa | ||
| notas:squid [2010/03/15 14:20] – creado cayu | notas:squid [2018/11/27 13:58] (actual) – [Formato de LOG] cayu | ||
|---|---|---|---|
| Línea 9: | Línea 9: | ||
| ===== Delay pools ===== | ===== Delay pools ===== | ||
| - | Por ejemplo si tengo usuarios que abusan del uso de internet, dado el caso de que bajan una iso y la dejan horas agotando el ancho de banda, lo que podemos hacer con Squid, es que cuando llegen a un tope, por ejemplo 15MB el ancho de banda baje considerablemente | + | Por ejemplo si tengo usuarios que abusan del uso de internet, dado el caso de que bajan una iso y la dejan horas agotando el ancho de banda, lo que podemos hacer con Squid, es que cuando llegen a un tope, por ejemplo 15MB el ancho de banda baje considerablemente |
| - | + | Ejemplo si un usuario baja un archivo ISO, cuando llega a los 15MB la velocidad baja a 16k/s para todo el segmento | |
| - | Ejemplo si un usuario baja un archivo ISO, cuando llega a los 15MB la velocidad baja a 16k/s | + | |
| < | < | ||
| delay_pools | delay_pools | ||
| Línea 54: | Línea 53: | ||
| \.zip$ | \.zip$ | ||
| + | |||
| + | youtube.com | ||
| </ | </ | ||
| + | Delay pool clase 2 para afectar a usuarios individuales | ||
| + | |||
| + | < | ||
| + | delay_pools | ||
| + | delay_class | ||
| + | delay_parameters | ||
| + | delay_access | ||
| + | </ | ||
| + | |||
| + | Ejemplo de Delay pool por horarios | ||
| + | |||
| + | < | ||
| + | acl winupdate dstdomain .windowsupdate.com | ||
| + | acl peakperiod time 10:00-16:00 | ||
| + | delay_pools 1 | ||
| + | delay_class 1 1 | ||
| + | # 64 Kbit/s | ||
| + | delay_parameters 1 8000/8000 | ||
| + | delay_access 1 allow winupdate peakperiod | ||
| + | </ | ||
| + | |||
| + | Sacado de : http:// | ||
| + | |||
| + | |||
| + | Otros ejemplos de delay pools | ||
| + | |||
| + | < | ||
| + | # 157 kB/s | ||
| + | delay_pools 1 | ||
| + | delay_class 1 2 | ||
| + | delay_parameters 1 98304/ | ||
| + | delay_access 1 allow all ancho_de_banda | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # 8 kB/s | ||
| + | delay_pools 1 | ||
| + | delay_class 1 1 | ||
| + | delay_parameters 1 8192/8192 | ||
| + | delay_access 1 allow all ancho_de_banda | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # 32 kB/s | ||
| + | delay_pools 1 | ||
| + | delay_class | ||
| + | delay_parameters 1 32768/ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # 50 kB/s | ||
| + | delay_pools 1 | ||
| + | delay_class | ||
| + | delay_parameters 1 65536/ | ||
| + | delay_access 1 allow all ancho_de_banda | ||
| + | </ | ||
| + | |||
| + | |||
| + | Ejemplo de dos proxys hermanos (sibling) | ||
| + | |||
| + | **squid.conf** | ||
| + | < | ||
| + | include squid-peers.conf | ||
| + | </ | ||
| + | |||
| + | // | ||
| + | |||
| + | < | ||
| + | cache_peer 10.1.1.2 | ||
| + | cache_peer 192.168.1.2 | ||
| + | cache_peer 192.168.1.3 | ||
| + | </ | ||
| + | |||
| + | // | ||
| + | |||
| + | < | ||
| + | cache_peer 10.1.1.3 | ||
| + | cache_peer 192.168.1.3 | ||
| + | cache_peer 192.168.1.2 | ||
| + | </ | ||
| + | |||
| + | ===== Bloquear MSN apto para 7 y 8 ===== | ||
| + | |||
| + | MSN Messenger 7 y MSN 8 tienen a buscar por todo lados como conectarse, entonces esto se vuelve algo medio problematico con Squid y mas cuando tenemos muchos grupos LDAP configurados y queremos que algunos si puedan acceder etc. Mi solución por el momento es : | ||
| + | |||
| + | < | ||
| + | acl MSN_Method method POST | ||
| + | acl MSN_Agent browser ^Mozilla.compatible; | ||
| + | acl MSN_Agent browser ^Mozilla/ | ||
| + | acl MSN_Mime req_mime_type ^application/ | ||
| + | acl MSN_Port port 1863 | ||
| + | acl MSN_Dom dstdom_regex -i messenger.hotmail.com 207.46.110.40 gateway.messenger.hotmail.com msn.com local-bay.contacts.msn.com messenger.live.com proxy-sn.contacts.msn.com proxy-bay.contacts.msn.com gateway.edge.messenger.live.com bay.messenger.services.live.com geo.messenger.services.live.com | ||
| + | acl MSN_Url url_regex -i gateway.dll sqmserver.dll ADSAdClient31.dll gateway.dll? | ||
| + | acl MSN_Usr | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | http_access | ||
| + | http_reply_access deny MSN_Agent MSN_Mime MSN_Dom MSN_Url !MSN_Usr | ||
| + | |||
| + | http_access | ||
| + | http_reply_access deny MSN_Method MSN_Url !MSN_Usr | ||
| + | |||
| + | http_access | ||
| + | http_reply_access deny CONNECT MSN_Port !MSN_Usr | ||
| + | </ | ||
| + | |||
| + | El reply acces es para forzar a que si o si se cumpla dicha condición, ya que podemos tener una gran cantidad de ACL's y algunas se pueden superponer, entonces con esto las forzamos. | ||
| + | |||
| + | |||
| + | ===== Autenticacion NTLM ===== | ||
| + | |||
| + | Para conocer el estado de una cuenta podemos ejecutar | ||
| + | |||
| + | < | ||
| + | # wbinfo -a [domain]\\[user]%[password] | ||
| + | plaintext password authentication failed | ||
| + | error code was NT_STATUS_ACCOUNT_LOCKED_OUT (0xc0000234) | ||
| + | error messsage was: Account locked out | ||
| + | Could not authenticate user GRUPODERED\soporte%Password1234 with plaintext password | ||
| + | challenge/ | ||
| + | error code was NT_STATUS_ACCOUNT_LOCKED_OUT (0xc0000234) | ||
| + | error messsage was: Account locked out | ||
| + | Could not authenticate user GRUPODERED\soporte with challenge/ | ||
| + | </ | ||
| + | |||
| + | Para ver la lista de usuarios del dominio | ||
| + | |||
| + | < | ||
| + | # wbinfo -u | ||
| + | </ | ||
| + | |||
| + | ===== Blacklist ===== | ||
| + | Listado de sitios prohibidos organizados por categorias. A continuacion describimos cada unas de las mismas: | ||
| + | |||
| + | ^Categoria^Descripcion^ | ||
| + | |ads | ||
| + | |adult | ||
| + | |aggressive | ||
| + | |antispyware | ||
| + | |artnudes | ||
| + | |astrology | ||
| + | |audio-video | ||
| + | |banking | ||
| + | |beerliquorinfo | ||
| + | |beerliquorsale | ||
| + | |Blog | ||
| + | |cellphones | ||
| + | |chat | ||
| + | |childcare | ||
| + | |cleaning | ||
| + | |clothing | ||
| + | |culnary | ||
| + | |dating | ||
| + | |desktopsillies | ||
| + | |dialers | ||
| + | |drugs | ||
| + | |ecommerce | ||
| + | |entertainment | ||
| + | |filehosting | ||
| + | |frencheducation | ||
| + | |gambling | ||
| + | |games | ||
| + | |gardening | ||
| + | |government | ||
| + | |guns | ||
| + | |hacking | ||
| + | |homerepair | ||
| + | |hygiene | ||
| + | |instantmessaging | ||
| + | |jewelry | ||
| + | |jobsearch | ||
| + | |kidstimewasting | ||
| + | |mail | ||
| + | |marketingware | ||
| + | |medical | ||
| + | |mixed_adult | ||
| + | |naturism | ||
| + | |news | ||
| + | |onlineauctions | ||
| + | |onlinegames | ||
| + | |onlinepayment | ||
| + | |personalfinance | ||
| + | |pets | ||
| + | |phishing | ||
| + | |porn | ||
| + | |proxy | ||
| + | |radio | ||
| + | |religion | ||
| + | |ringtones | ||
| + | |searchengines | ||
| + | |sect | ||
| + | |sexuality | ||
| + | |shopping | ||
| + | |socialnetworking | ||
| + | |sportnews | ||
| + | |sports | ||
| + | |spyware | ||
| + | |updatesites | ||
| + | |vacation | ||
| + | |violence | ||
| + | |virusinfected | ||
| + | |warez | ||
| + | |weather | ||
| + | |weapons | ||
| + | |webmail | ||
| + | |whitelist | ||
| + | === Referencias === | ||
| + | ^URL^Descripción^ | ||
| + | |http:// | ||
| + | |http:// | ||
| + | |http:// | ||
| + | |http:// | ||
| + | |||
| + | ===== Formato de LOG ===== | ||
| + | |||
| + | == Cambiar formato de logs == | ||
| + | |||
| + | Agregar la directiva // | ||
| + | |||
| + | == time.sh == | ||
| + | |||
| + | //Script a cual por medio de una pipe se le envia el access.log, lo analiza y nos interpreta el formato de fecha// **UNIX** //a formato de fecha// **Human Readable** :-P. | ||
| + | <code bash> | ||
| + | cat access.log | perl -p -e ' | ||
| + | </ | ||
| + | Otra opción : | ||
| + | <code perl> | ||
| + | # | ||
| + | |||
| + | s/ | ||
| + | </ | ||
| + | |||
| + | |||
| + | Enlace interesante: | ||
| + | |||
| + | ===== Información de Squid ===== | ||
| + | |||
| + | Si queremos ver los mensajes de error de Squid traducidos | ||
| + | |||
| + | < | ||
| + | error_directory / | ||
| + | </ | ||
| + | |||
| + | |||
| + | Si queremos ocultar la versión del Squid a mostrar | ||
| + | |||
| + | < | ||
| + | httpd_suppress_version_string on | ||
| + | </ | ||
| + | |||
| + | Si queremos modificar el nombre del host a mostrar en el mensaje de error | ||
| + | |||
| + | < | ||
| + | visible_hostname mihostproxy | ||
| + | </ | ||
| + | |||
| + | Enlace interesante: | ||
| + | |||
| + | ===== Script para ver los top sites ===== | ||
| + | |||
| + | <code perl> | ||
| + | # | ||
| + | ## | ||
| + | ## Squid Top Sites reporting script. | ||
| + | ## | ||
| + | ## Description: | ||
| + | ## This script will parse the specified squid logfile and count up the | ||
| + | ## | ||
| + | ## sites. | ||
| + | ## | ||
| + | ## Author: | ||
| + | ## Dave Hope - http:// | ||
| + | ## Sava Chankov ( Author of squid-report.pl ) | ||
| + | ## | ||
| + | ## Known Issues: | ||
| + | ## + Requests to the webserver on the proxy give weird results? | ||
| + | ## | ||
| + | ## Changelog: | ||
| + | ## | ||
| + | ## 1.0.1 | ||
| + | ## + Changed to have configuration held in-file. | ||
| + | ## + Removed last-visited date. | ||
| + | ## + Consolidated sites with/ | ||
| + | ## + Improved UI slightly. | ||
| + | ## 1.0.2 | ||
| + | ## + Fixed issue with accessing on ports other than 80. | ||
| + | ## + Fixed promblem with ftp:// entries in log. | ||
| + | ## | ||
| + | ## 1.2.0 | ||
| + | ## + Added ability to sort by size, rather than frequency. | ||
| + | ## | ||
| + | ## License: | ||
| + | ## This program is free software; you can redistribute it and/or modify it | ||
| + | ## under the GNU General Public License. | ||
| + | ## | ||
| + | ## This script is based on ' | ||
| + | ## been adjusted for my specific requirements. | ||
| + | ## | ||
| + | ## The original script can be found here: | ||
| + | ## | ||
| + | ## | ||
| + | |||
| + | use strict; | ||
| + | |||
| + | ## | ||
| + | # Configuration. | ||
| + | ## | ||
| + | my $cfgNumberToShow = 250; | ||
| + | my $cfgLog = "/ | ||
| + | my $cfgOutput = "/ | ||
| + | |||
| + | # by_times_visited_then_name or by_size_then_name | ||
| + | my $cfgSortMethod = " | ||
| + | |||
| + | |||
| + | ## | ||
| + | # Stop editing here unless you know what you're doing. | ||
| + | ## | ||
| + | my $cfgDate = gmtime; | ||
| + | my $row; | ||
| + | my($epoch_time_miliseconds, | ||
| + | my($unknown_integer2, | ||
| + | my($site_url, | ||
| + | |||
| + | |||
| + | ## | ||
| + | # Open output file | ||
| + | ## | ||
| + | open(OUTPUT, | ||
| + | |||
| + | |||
| + | ## | ||
| + | # Print header HTML | ||
| + | ## | ||
| + | print OUTPUT << | ||
| + | < | ||
| + | <html xmlns=" | ||
| + | <head profile=" | ||
| + | < | ||
| + | <meta http-equiv=" | ||
| + | <style type=" | ||
| + | <!-- | ||
| + | body { font: normal 1.0em ' | ||
| + | ul { list-style-type: | ||
| + | ul a { position: absolute; left: 150px } | ||
| + | # | ||
| + | #Footer { color: #cecece; line-height: | ||
| + | --> | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <p id=" | ||
| + | <ul> | ||
| + | END | ||
| + | |||
| + | |||
| + | ## | ||
| + | # Iterate through lines inaccess.log | ||
| + | ## | ||
| + | open(LOG, " | ||
| + | | ||
| + | while(< | ||
| + | { | ||
| + | $row = $_; | ||
| + | |||
| + | ($epoch_time_miliseconds, | ||
| + | |||
| + | # Not checking for http:// etc because we want to include CONNECT' | ||
| + | # multi-protocol data. | ||
| + | $url =~ s/ | ||
| + | $url =~ s/ | ||
| + | $url =~ s/www.//; | ||
| + | $url =~ s/\/$//; | ||
| + | |||
| + | # If the url is empty (which occurs occasionally in my logs, no idea | ||
| + | # why, then don't add it to the list. | ||
| + | if (!$url ) | ||
| + | { | ||
| + | next; | ||
| + | } | ||
| + | |||
| + | # Patern match data between slashes. | ||
| + | ($site_url) = ($url =~ m{ ([A-Za-z0-9.\-: | ||
| + | |||
| + | # Only match html content. | ||
| + | if($content_type =~ m{text/ | ||
| + | { | ||
| + | # If hash already contains an entry for the exact URL. | ||
| + | if ($sites{$site_url}) | ||
| + | { | ||
| + | | ||
| + | } | ||
| + | # If no matching entry exists, create one. | ||
| + | else | ||
| + | { | ||
| + | $sites{$site_url}-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Update size of content for website regardless of content-type. | ||
| + | if (!$sites{$site_url}-> | ||
| + | { | ||
| + | $sites{$site_url}-> | ||
| + | } | ||
| + | $sites{$site_url}-> | ||
| + | } | ||
| + | |||
| + | |||
| + | ## | ||
| + | # Iterate through visited sites. | ||
| + | ## | ||
| + | foreach $site_url ( sort ($cfgSortMethod keys (%sites) ) ) | ||
| + | { | ||
| + | # Only show top x entries. | ||
| + | if ($cfgNumberToShow > 0) | ||
| + | { | ||
| + | if ($cfgSortMethod eq " | ||
| + | { | ||
| + | print OUTPUT " | ||
| + | } | ||
| + | elsif ($cfgSortMethod eq " | ||
| + | { | ||
| + | print OUTPUT " | ||
| + | } | ||
| + | |||
| + | $cfgNumberToShow--; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | ## | ||
| + | # Print Footer HTML | ||
| + | ## | ||
| + | print OUTPUT << | ||
| + | </ | ||
| + | <div id=" | ||
| + | </ | ||
| + | </ | ||
| + | END | ||
| + | |||
| + | |||
| + | ## | ||
| + | # Sort sites by frequency visited, then alphabetically. | ||
| + | ## | ||
| + | sub by_times_visited_then_name { | ||
| + | $sites{$b}-> | ||
| + | || | ||
| + | $a cmp $b | ||
| + | } | ||
| + | |||
| + | ## | ||
| + | # Sort by size, then alphabetically. | ||
| + | ## | ||
| + | sub by_size_then_name { | ||
| + | $sites{$b}-> | ||
| + | || | ||
| + | $a cmp $b | ||
| + | } | ||
| + | |||
| + | # | ||
| + | # Version: 1.0 | ||
| + | # Copyright: Bryant H. McGill - 11c Lower Dorset Street, Dublin 1, Ireland | ||
| + | # Web Address: http:// | ||
| + | # Use Terms: Free for non-commercial use, commercial use with notification. | ||
| + | # | ||
| + | # Legal: This code is provided "as is" without warranty of any kind. | ||
| + | # The entire risk of use remains with the recipient. | ||
| + | # In no event shall Bryant McGill be liable for any direct, | ||
| + | # consequential, | ||
| + | # | ||
| + | sub format_size{ | ||
| + | my($bytes) = @_; | ||
| + | |||
| + | return '' | ||
| + | |||
| + | my($size); | ||
| + | $size = $bytes . ' Bytes' if ($bytes < 1024); | ||
| + | $size = sprintf(" | ||
| + | $size = sprintf(" | ||
| + | $size = sprintf(" | ||
| + | $size = sprintf(" | ||
| + | |||
| + | return $size; | ||
| + | } | ||
| + | </ | ||
notas/squid.1268662800.txt.gz · Última modificación: 2010/03/15 14:20 por cayu
