+
+ <p>Per installare Squid si usino i pacchetti:</p>
+ <pre class="literal-block">
+squid3
+</pre>
+
+ <div class="section" id="configurazione-squid-conf">
+ <h2><a class="toc-backref" href=
+ "#id17">2.1 Configurazione:
+ squid.conf</a></h2>
+
+ <p>Segue un estratto del file di configurazione:</p>
+ <pre class="literal-block">
+#TAG: cache_dir (1628)
+# Usage:
+#
+# cache_dir Type Directory-Name Fs-specific-data [options]
+#
+# You can specify multiple cache_dir lines to spread the
+# cache among different disk partitions.
+# ...
+#Default:
+# cache_dir ufs /var/spool/squid3 100 16 256
+cache_dir aufs /var/spool/squid3 300 24 256
+# algoritmo
+# path della cache
+# dimensione in MB
+# directory primo livello
+# secondo livello di directory
+</pre>
+
+ <p>Se si modifica la struttura del filesytem della cache di
+ Squid, ad esempio variando il numero delle directory, puo'
+ essere (ed in genere lo e') opportuno rigenerare la
+ struttura della cache di squid. Tipicamente e' opportuno
+ cancellare la vecchia cache e poi generarne una nuova:</p>
+ <pre class="literal-block">
+# /etc/init.d/squid3 stop
+# rm -r /var/spool/squid3/??
+# squid3 -z
+# /etc/init.d/squid3 start
+</pre>
+
+ <div class="section" id="tag-maximum-object-size">
+ <h3><a class="toc-backref" href=
+ "#id18">2.1.1 TAG:
+ maximum_object_size</a></h3>
+
+ <p>Questa direttiva imposta la dimensione massima degli
+ oggetti che vengono slvati sul supporto di storaggio,
+ oggetti di dimensioni superiori verranno scaricati ma non
+ tenuti in cache.</p>
+
+ <p>TAG: maximum_object_size (1760):</p>
+ <pre class="literal-block">
+# TAG: maximum_object_size (1760)
+# Objects larger than this size will NOT be saved on disk. The
+# value is specified in kilobytes, and the default is 4MB. If
+# you wish to get a high BYTES hit ratio, you should probably
+# increase this (one 32 MB object hit counts for 3200 10KB
+# hits). If you wish to increase speed more than your want to
+# save bandwidth you should leave this low.
+#
+# NOTE: if using the LFUDA replacement policy you should increase
+# this value to maximize the byte hit rate improvement of LFUDA!
+# See replacement_policy below for a discussion of this policy.
+#
+#Default:
+# maximum_object_size 4096 KB
+maximum_object_size 150 MB
+</pre>
+ </div>
+
+ <div class="section" id="tag-cache-mem">
+ <h3><a class="toc-backref" href=
+ "#id19">2.1.2 TAG: cache_mem</a></h3>
+
+ <p><em>Cache_mem</em> imposta quanta memoria RAM
+ utilizzare per la cache di Squid. Questo dipendera' dalla
+ RAM disponibile sul sistema, e da quanta di questa volete
+ mettere a disposizione di Squid. Questo paramentro
+ influisce sulle prestazioni e sul degrado dei supporti di
+ storaggio (sopratutto se magnetici).</p>
+
+ <p>TAG: cache_mem (1566):</p>
+ <pre class="literal-block">
+# 'cache_mem' specifies the ideal amount of memory to be used
+# for:
+# * In-Transit objects
+# * Hot Objects
+# * Negative-Cached objects
+#Default:
+# cache_mem 8 M
+cache_mem 100 M
+</pre>
+ </div>
+
+ <div class="section" id="tag-minimum-object-size">
+ <h3><a class="toc-backref" href=
+ "#id20">2.1.3 TAG:
+ minimum_object_size</a></h3>
+
+ <p>Questo paramentro imposta la dimensione minima degli
+ oggetti salvati nella cache. Settato a <tt class=
+ "docutils literal"><span class="pre">0</span></tt> o a
+ valori molto piccoli puo' influire negativamente sulla
+ deframmentazione del filesytem e consumare un numero
+ elevato di <em>inode</em>.</p>
+
+ <p>TAG: minimum_object_size:</p>
+ <pre class="literal-block">
+# TAG: minimum_object_size (bytes)
+# Objects smaller than this size will NOT be saved on disk. The
+# value is specified in kilobytes, and the default is 0 KB, which
+# means there is no minimum.
+#
+#Default:
+# minimum_object_size 0 KB
+minimum_object_size 0 KB
+</pre>
+ </div>
+ </div>
+
+ <div class="section" id=
+ "negoziazione-degli-accesi-al-servizio">
+ <h2><a class="toc-backref" href=
+ "#id21">2.2 Negoziazione degli accesi al
+ servizio</a></h2>
+
+ <p>Squid e' uno di quei servizi soggetto a problemi di tipo
+ <em>open relay</em>, si deve quindi limitare la rete che
+ puo' accedere al servizio.</p>
+
+ <div class="section" id="acl-e-http-access">
+ <h3><a class="toc-backref" href=
+ "#id22">2.2.1 ACL e http access</a></h3>
+
+ <p>Si proceda a creare una <tt class=
+ "docutils literal"><span class="pre">ACL</span></tt> di
+ tipo <tt class="docutils literal"><span class=
+ "pre">src</span></tt> per identificare la lostra rete
+ locale, poi si abiliti l'accesso a questa con la
+ direttiva <tt class="docutils literal"><span class=
+ "pre">http_access</span></tt>. Tutto quanto non e'
+ espressamente autorizzato viene poi negato da un
+ <tt class="docutils literal"><span class=
+ "pre">http_access</span> <span class="pre">deny</span>
+ <span class="pre">all</span></tt> finale.</p>
+ <pre class="literal-block">
+# TAG: acl
+# Defining an Access List
+#
+# Every access list definition must begin with an aclname and acltype,
+# followed by either type-specific arguments or a quoted filename that
+# they are read from.
+# ...
+# ***** ACL TYPES AVAILABLE *****
+#
+# acl aclname src ip-address/netmask ... # clients IP address
+# riga 588
+
+# 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 10.10.208.0/24
+# Riga 606
+# TAG: http_access
+# Allowing or Denying access based on defined access lists
+#
+# Access to the HTTP port:
+# http_access allow|deny [!]aclname ...
+#
+# NOTE on default values:
+#
+# If there are no "access" lines present, the default is to deny
+# the request.
+
+# Riga 643
+# 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 localnet
+</pre>
+ </div>
+ </div>
+
+ <div class="section" id="testare-squid">
+ <h2><a class="toc-backref" href=
+ "#id23">2.3 Testare Squid</a></h2>
+
+ <p>Configurato squid e' fondamentale testarne il corretto
+ funzionamento per assicurarsi di non aver creato un
+ <em>open-relay</em>. Per fare dei test significativi serve
+ utilizzare degli host remoti: ci si connetta via ssh a
+ questi per poi utilizzare <tt class=
+ "docutils literal"><span class="pre">wget</span></tt> da
+ riga di comando.</p>
+
+ <div class="section" id="wgetrc">
+ <h3><a class="toc-backref" href=
+ "#id24">2.3.1 wgetrc</a></h3>
+
+ <p>Nel file <tt class="docutils literal"><span class=
+ "pre">.wgetrc</span></tt> (si noti il punto iniziale: e'
+ un file nascosto) si puo' impostare il proxy per wget. Si
+ utililizzi l'indirizzo ip del server che si vuole
+ testare, e si seguano i log <tt class=
+ "docutils literal"><span class=
+ "pre">/var/log/squid3/access.log</span></tt> sul
+ server.</p>
+
+ <p>Da notare che la prova va' fatta su una macchina della
+ rete che si vuole testare, non da <em>localhost</em>. Per
+ altro se si utilizzasse <em>direttamente</em> <tt class=
+ "docutils literal"><span class=
+ "pre">localhost</span></tt> non si testerebbe la
+ <em>ACL</em> predisposta, dato che si si rientrerebbe
+ nella ACL (pre-configurata di default) <tt class=
+ "docutils literal"><span class=
+ "pre">localhost</span></tt>.</p>
+
+ <dl class="docutils">
+ <dt>.wgetrc</dt>
+
+ <dd>http_proxy=10.10.208.178:3128</dd>
+ </dl>
+
+ <p>Si proceda a scaricare dal client scelto con un
+ wget:</p>
+ <pre class="literal-block">
+wget http://www.google.it
+</pre>
+
+ <p>Si puo' controllare il corretto funzionamento del
+ server seguendo i log di accesso a Squid:</p>
+ <pre class="literal-block">
+# tail -f /var/log/squid3/access.log
+</pre>
+ </div>
+ </div>