I.
Pengertian Squid
Squid adalah sebuah daemon yang digunakan sebagai proxy
server
dan web cache. Squid memiliki banyak jenis penggunaan,
mulai dari mempercepat server web dengan melakukan caching permintaan yang
berulang-ulang, caching DNS, caching situs web, dan caching pencarian komputer di dalam jaringan untuk sekelompok komputer yang menggunakan sumber daya jaringan yang
sama, hingga membantu keamanan dengan cara melakukan penyaringan (filter) lalu lintas. Meskipun seringnya digunakan untuk protokol HTTP dan FTP, Squid juga
menawarkan dukungan terbatas untuk beberapa protokol lainnya termasuk Transport Layer Security (TLS), Secure Socket Layer (SSL), Internet Gopher, dan HTTPS. Versi Squid 3.1
mencakup dukungan protokol IPv6 dan Internet Content Adaptation Protocol (ICAP).
II.
Fungsi Squid
Squid
adalah high-performance proxy
caching server untuk web klien, yang sudah mendukung FTP, ghoper, dan HTTP data
object. Berbeda dengan software caching yang lama, squid menangani semua
permintaan tunggal (single), non-blocking, I/O-driven proses.
Squid menyimpan meta data dan terutama hot-object yang di
simpan di RAM, menyimpan DNS lookups, mendukung non-blocking DNS lookups, dan
implementasi negative-caching jika permintaan gagal.
Squid mendukung SSL, access kontrol yang banyak, dan full
request logging. Dengan menggunakan lightweight internet cache protokol, squid
cache dapat dibuat dalam suatu hirarki atau mesh untuk meningkatkan penghematan
bandwidth.
Squid terdiri dari program server utama squid, sebuah Domain
Name System lookup (program dnsserver), beberapa program tambahan untuk
permintaan menulis ulang dan melakukan authentication, dan beberapa tools
management client. Ketika squid dijalankan, itu akan menambah jumlah proses
dnsserver, masing-masing bertugas sendiri-sendiri, blocking Domain Name System
(DNS) lookup. Ini akan mengurangi waktu tunggu DNS lookups
III.
Sejarah Squid
Squid pada awalnya dikembangkan oleh Duane Wessels sebagai "Harvest object
cache", yang merupakan bagian dari proyek Harvest yang dikembangkan
di University of Colorado at Boulder. Pekerjaan selanjutnya dilakukan hingga
selesai di University of California, San Diego dan didanai melalui National Science Foundation. Squid kini hampir secara eksklusif dikembangkan dengan cara usaha
sukarela.
Squid umumnya didesain untuk berjalan di
atas sistem operasi mirip UNIX, meski Squid juga bisa berjalan di atas sistem operasi Windows. Karena dirilis di
bawah lisensi GNU General Public License, maka Squid merupakan perangkat lunak bebas
IV.
Platform Pendukung Squid
Squid dapat berjalan dengan baik terutama pada sistem
operasi berikut :
- — AIX
- — BSDI
- — Digital Unix
- — FreeBSD
- — HP-UX
- — IRIX
- — Linux
- — Mac OS X
- — NetBSD
- — NeXTStep
- — OpenBSD
- — SCO OpenServer
- — Solaris
- — UnixWare
- — Windows
V.
Optimasi Squid Pada File System (Disk dan ReiserFS)
A.
Squid diskd
DISKD mengacu pada beberapa fitur di squid-2.4 untuk meningkatkan Disk I
/ O kinerja. Ide dasarnya adalah bahwa cache_dir masing-masing memiliki
proses sendiri pada diskd nya. Proses diskd melakukan semua I / O
operasi (membuka, menutup, membaca, menulis, unlink) untuk cache_dir tersebut.
Antrian pesan digunakan untuk mengirim
permintaan dan tanggapan antara Squid dan proses diskd.jadi konsep nya seperti
Memori bersama yang digunakan untuk potongan data yang akan dibaca dan ditulis. Jika
diskd dikombinasikan dengan squid maka kita akan mendapatkan hasil bakeoff yang
lebih optimal jika memakai disk . Pada bakeoff dengan memakai disk kita bisa
mendapatkan 160 req / detik , sedangkan
tanpa disk kita hanya mendapatkan sekitar 40 req / detik.
B. ReiserFS
ReiserFS adalah filesystem journalling
patchnya dengan mudah masuk ke dalam 2,2 kernel terbaru seri. ReiserFS
adalah signifikan lebih cepat daripada ext2 ketika berhadapan dengan ribuan
file kecil. Karena file kecil cukup banyak semua penawaran web cache dengan,
kita akan menggunakan ReiserFS pada partisi cache yang kita. Anda dapat
menemukan ReiserFS di <
http://www.namesys.com/ >. Manfaat tambahan dari FS journalled adalah bahwa dalam hal suatu
shutdown abnormal sistem anda akan pulih lebih cepat dan tanpa kehilangan
banyak sebagai file sebagai ext2.
VI.
Pengoptimalan
Jadi demi mengoptimalkan proses
caching nya kita harus memerhatikan komponen ,yaitu sebagai berikut :
·
Hard disk
Anda
perlu menggunakan s 7200 RPM UDMA 66 drives atau fast (7200 atau 10k RPM) SCSI
drive. Sebuah UDMA baik 66 drive dengan controller yang tepat dapat
melakukan drive SCSI sebanding biaya
yang lebih murah. Namun, jika Anda memilih UDMA, perlu diingat bahwa CPU akan
perlu sedikit lebih cepat untuk menebus siklus tambahan yang digunakan untuk I
/ O.
·
Prosesor
Squid
dalam konfigurasi default, seperti yang ditemukan dalam RPM atau dalam
kompilasi standar, tidak membutuhkan CPU yang sangat cepat untuk mendukung 1
atau 2 disk. Namun, peningkatan kinerja yang besar dapat dicapai dengan
menggunakan versi ulir dari squid. Benang akan menggunakan banyak tenaga CPU.
pertimbangkan untuk mendapatkan prosesor lebih cepat. Sebuah prosesor dengan
kapasitas 550MHz K6-2 adalahmerupakan yang kompatibel. Pengaruh kecepatan
sangat mempengaruhi sistem disk tunggal atau ganda.
·
RAM
cukup
mudah untuk menghitung jumlah RAM yang dibutuhkan untuk setiap web cache. Untuk
mendapatkan kompabilitas yang sesuai cukup dengan 10MB RAM untuk setiap 1 GB
ruang cache pada disk. Biasanya dibagi lebih
dari ini ketika menggunakan Squid threaded. Tentu saja, Anda juga perlu
mencari tahu sistem apa yang a anda gunakan untuk hal lain . Untuk unit
prototipe disarankan memakai 256 mb
VII.
Kofigurasi
Paket-paket
yang dibutuhkan :
-
compiler gcc dan tool pendukung compiler (development program)
- malloc, program memori utilisasi
- Squid source program (tarball)
- malloc, program memori utilisasi
- Squid source program (tarball)
Download
paket dan install :
root@proxy
root# mkdir /download
root@proxy download# cd /download
root@proxy download# wget http://www.squid-cache.org/Versions/v2/2.5/squid-2.5.STABLE10.tar.gz
root@proxy download# wget ftp://ftp.gnu.org/gnu/malloc.tar.gz
root@proxy download# cd /download
root@proxy download# wget http://www.squid-cache.org/Versions/v2/2.5/squid-2.5.STABLE10.tar.gz
root@proxy download# wget ftp://ftp.gnu.org/gnu/malloc.tar.gz
Sebelum
installasi squid, pastikan program squid lama anda yang mungkin sudah
terinstall di sistem untuk di uninstall dulu.
root@proxy
root# rpm -qa |grep squid
squid-2.5STABLE6
root@proxy root# rpm -e squid-2.5STABLE6
squid-2.5STABLE6
root@proxy root# rpm -e squid-2.5STABLE6
Installasi
semua paket squid :
root@proxy
download# tar xzf malloc.tar.gz
root@proxy download# cd malloc
root@proxy malloc# vi Makefile
—-semula—–
# Use this on System V.
#CPPFLAGS = -DUSG
—————
root@proxy download# cd malloc
root@proxy malloc# vi Makefile
—-semula—–
# Use this on System V.
#CPPFLAGS = -DUSG
—————
diubah
—
—-menjadi—–
# Use this on System V.
CPPFLAGS = -DUSG
—————
# Use this on System V.
CPPFLAGS = -DUSG
—————
root@proxy
malloc# make
root@proxy malloc# cp libmalloc.a /usr/lib/libgnumalloc.a
root@proxy malloc# cp malloc.h /usr/include/gnumalloc.h
root@proxy malloc# cp libmalloc.a /usr/lib/libgnumalloc.a
root@proxy malloc# cp malloc.h /usr/include/gnumalloc.h
Tunning
system sebelum installasi squid (ini maksudnya, untuk mengaktifkan langsung
pada saat kompile squid), tujuannya untuk menaikkan File Deskriptor (FD) ,
memperbesar proses penggunaan file :
root@proxy
malloc# vi /etc/security/limits.conf
* Soft nofile 2048
* Hard nofile 2048
root@proxy malloc# ulimit -HSn 2048
root@proxy malloc# ulimit -n
4096
* Soft nofile 2048
* Hard nofile 2048
root@proxy malloc# ulimit -HSn 2048
root@proxy malloc# ulimit -n
4096
Installasi
Core Squid program :
root@proxy
malloc# cd /download
root@proxy download# tar squid-2.5.STABLE10.tar.gz
root@proxy download# cd squid-2.5.STABLE10
root@proxy squid-2.5.STABLE10# ./configure \
–prefix=/usr –exec-prefix=/usr –bindir=/usr/bin \
–sbindir=/usr/sbin –libexecdir=/usr/libexec \
–datadir=/usr/share/squid –sysconfdir=/etc/squid \
–sharedstatedir=/usr/com –localstatedir=/var \
–libdir=/usr/lib –includedir=/usr/include \
–infodir=/usr/share/info –mandir=/usr/share/man \
–libexecdir=/usr/lib/squid \
–enable-gnuregex \
–enable-async-io=24 \
–with-aufs-threads=24 \
–with-pthreads \
–with-aio \
–with-dl \
–enable-storeio=aufs \
–enable-removal-policies=heap \
–enable-icmp \
–enable-delay-pools \
–disable-wccp \
–enable-snmp \
–enable-ssl \
–enable-cache-digests \
–enable-default-err-languages=English \
–enable-err-languages=English \
–enable-poll \
–enable-linux-netfilter \
–disable-ident-lookups \
–disable-hostname-checks \
–enable-underscores \
–enable-cachemgr-hostname=localhost
root@proxy download# tar squid-2.5.STABLE10.tar.gz
root@proxy download# cd squid-2.5.STABLE10
root@proxy squid-2.5.STABLE10# ./configure \
–prefix=/usr –exec-prefix=/usr –bindir=/usr/bin \
–sbindir=/usr/sbin –libexecdir=/usr/libexec \
–datadir=/usr/share/squid –sysconfdir=/etc/squid \
–sharedstatedir=/usr/com –localstatedir=/var \
–libdir=/usr/lib –includedir=/usr/include \
–infodir=/usr/share/info –mandir=/usr/share/man \
–libexecdir=/usr/lib/squid \
–enable-gnuregex \
–enable-async-io=24 \
–with-aufs-threads=24 \
–with-pthreads \
–with-aio \
–with-dl \
–enable-storeio=aufs \
–enable-removal-policies=heap \
–enable-icmp \
–enable-delay-pools \
–disable-wccp \
–enable-snmp \
–enable-ssl \
–enable-cache-digests \
–enable-default-err-languages=English \
–enable-err-languages=English \
–enable-poll \
–enable-linux-netfilter \
–disable-ident-lookups \
–disable-hostname-checks \
–enable-underscores \
–enable-cachemgr-hostname=localhost
Catatan:
7 baris paling atas adalah penyesuaian konfigurasi dari sistem yang ada di
redhat/fedora. dan untuk opsi-opsi silahkan kompile jika dibutuhkan, kalau
tidak dibutuhkan jangan dimasukkan pada saat kompile.
root@proxy
squid-2.5.STABLE10# mkdir /var/log/squid
root@proxy squid-2.5.STABLE10# chown -R squid:squid /var/log/squid
root@proxy squid-2.5.STABLE10# make all && make install
root@proxy squid-2.5.STABLE10# strip /usr/lib/squid/*
root@proxy squid-2.5.STABLE10# strip /usr/sbin/squid
root@proxy squid-2.5.STABLE10# chown -R squid:squid /var/log/squid
root@proxy squid-2.5.STABLE10# make all && make install
root@proxy squid-2.5.STABLE10# strip /usr/lib/squid/*
root@proxy squid-2.5.STABLE10# strip /usr/sbin/squid
3.
Konfigurasi dan Optimasi squid
Konfigurasi
squid :
http_port
3128
icp_port 3130
ssl_unclean_shutdown on
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 6 MB
cache_swap_low 98
cache_swap_high 99
maximum_object_size 64 MB
maximum_object_size_in_memory 16 KB
ipcache_size 8192
ipcache_low 98
ipcache_high 99
fqdncache_size 8192
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
cache_dir aufs /cache01 5000 10 256
cache_access_log /var/log/squid/access.log
#cache_access_log none
cache_log /var/log/squid/cache.log
cache_store_log none
emulate_httpd_log off
pid_filename /var/run/squid.pid
mime_table /etc/squid/mime.conf
log_fqdn off
memory_pools off
client_netmask 255.255.255.255
ftp_user squid@domainku.web
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on
refresh_pattern ^ftp: 40320 95% 241920 reload-into-ims
refresh_pattern . 120 50% 14400
quick_abort_min 0
quick_abort_max 0
quick_abort_pct 98
negative_ttl 2 minutes
half_closed_clients off
read_timeout 15 minutes
client_lifetime 2 hours
pconn_timeout 60 seconds
request_timeout 1 minutes
shutdown_lifetime 10 seconds
positive_dns_ttl 60 seconds
negative_dns_ttl 30 seconds
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1
acl lan src 192.168.0.0/24 192.168.1.0/24
acl to_localhost dst 127.0.0.0/8
acl PURGE method PURGE
acl POST method POST
acl IpAddressOnly url_regex ^http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/$
acl IpAddressOnly url_regex ^http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$
acl GETONLY method GET
acl VIRUS urlpath_regex winnt/system32/cmd.exe?
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
acl snmppublic snmp_community public
# Hotmail workaround
header_access Accept-Encoding deny all
http_access allow localhost
http_access allow lan
http_access allow manager lan
http_access allow PURGE localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny PURGE
http_access deny VIRUS
http_access deny all
http_reply_access allow all
icp_access allow lan
icp_access deny all
miss_access allow lan
miss_access deny all
cachemgr_passwd passwordku all
cache_mgr proxyadmin@domainku.web
cache_effective_user squid
cache_effective_group squid
visible_hostname proxies3.domainku.web.id
unique_hostname proxy.domainku.web.id
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
httpd_accel_no_pmtu_disc on
logfile_rotate 7
forwarded_for on
icp_hit_stale on
log_icp_queries off
query_icmp on
buffered_logs off
strip_query_terms off
icon_directory /usr/share/squid/icons
error_directory /usr/share/squid/errors/English
store_avg_object_size 13 KB
store_objects_per_bucket 10
client_db on
snmp_port 3401
snmp_access allow snmppublic lan
snmp_access deny all
coredump_dir /cache01
reload_into_ims on
pipeline_prefetch on
ie_refresh on
vary_ignore_expire on
icp_port 3130
ssl_unclean_shutdown on
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 6 MB
cache_swap_low 98
cache_swap_high 99
maximum_object_size 64 MB
maximum_object_size_in_memory 16 KB
ipcache_size 8192
ipcache_low 98
ipcache_high 99
fqdncache_size 8192
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
cache_dir aufs /cache01 5000 10 256
cache_access_log /var/log/squid/access.log
#cache_access_log none
cache_log /var/log/squid/cache.log
cache_store_log none
emulate_httpd_log off
pid_filename /var/run/squid.pid
mime_table /etc/squid/mime.conf
log_fqdn off
memory_pools off
client_netmask 255.255.255.255
ftp_user squid@domainku.web
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on
refresh_pattern ^ftp: 40320 95% 241920 reload-into-ims
refresh_pattern . 120 50% 14400
quick_abort_min 0
quick_abort_max 0
quick_abort_pct 98
negative_ttl 2 minutes
half_closed_clients off
read_timeout 15 minutes
client_lifetime 2 hours
pconn_timeout 60 seconds
request_timeout 1 minutes
shutdown_lifetime 10 seconds
positive_dns_ttl 60 seconds
negative_dns_ttl 30 seconds
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1
acl lan src 192.168.0.0/24 192.168.1.0/24
acl to_localhost dst 127.0.0.0/8
acl PURGE method PURGE
acl POST method POST
acl IpAddressOnly url_regex ^http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/$
acl IpAddressOnly url_regex ^http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$
acl GETONLY method GET
acl VIRUS urlpath_regex winnt/system32/cmd.exe?
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
acl snmppublic snmp_community public
# Hotmail workaround
header_access Accept-Encoding deny all
http_access allow localhost
http_access allow lan
http_access allow manager lan
http_access allow PURGE localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny PURGE
http_access deny VIRUS
http_access deny all
http_reply_access allow all
icp_access allow lan
icp_access deny all
miss_access allow lan
miss_access deny all
cachemgr_passwd passwordku all
cache_mgr proxyadmin@domainku.web
cache_effective_user squid
cache_effective_group squid
visible_hostname proxies3.domainku.web.id
unique_hostname proxy.domainku.web.id
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
httpd_accel_no_pmtu_disc on
logfile_rotate 7
forwarded_for on
icp_hit_stale on
log_icp_queries off
query_icmp on
buffered_logs off
strip_query_terms off
icon_directory /usr/share/squid/icons
error_directory /usr/share/squid/errors/English
store_avg_object_size 13 KB
store_objects_per_bucket 10
client_db on
snmp_port 3401
snmp_access allow snmppublic lan
snmp_access deny all
coredump_dir /cache01
reload_into_ims on
pipeline_prefetch on
ie_refresh on
vary_ignore_expire on
Tips
Optimasi Squid :
Jika
ada beberapa situs terdekat yg mungkin hanya 1 hop, di-by pass saja supaya
kerja Squid benar-benar utk yg jaraknya jauh (hopnya banyak).
hierarchy_stoplist
cgi-bin ? localhost domain-anda.com isp-anda.com domainku.web.id
acl QUERY urlpath_regex cgi-bin \? localhost domain-anda.com isp-anda.com domainku.web.id
no_cache deny QUERY
acl QUERY urlpath_regex cgi-bin \? localhost domain-anda.com isp-anda.com domainku.web.id
no_cache deny QUERY
Dari
pengalaman dan rekomendasi 6 MB akan lebih cepat dan biarkan Squid bekerja
lebih keras lagi.
cache_mem
6 MB
cache_swap_low 98
cache_swap_high 99
cache_swap_low 98
cache_swap_high 99
Maksimum
obyek di hardisk dan di memori diupayakan lebih besar shg byte hit lebih tinggi
(bisa dinaikkan lagi jika hardisk berkecepatan tinggi dan jumlahnya banyak dg
memori yg lebih besar pula).
maximum_object_size
128 MB
maximum_object_size_in_memory 32 KB
maximum_object_size_in_memory 32 KB
Jika
memori 512 MB atau lebih besar silahkan cache diperbesar.
ipcache_size
2048
ipcache_low 98
ipcache_high 99
ipcache_low 98
ipcache_high 99
Untuk
heap replacement saya memakai LFUDA utk cache hardisk dan GDSF utk cache memori
dg alasan di hardisk diprioritaskan obyek yg ukuran besar-besar dan di memori
obyek yg ukurannya kecil-kecil utk disimpan.
cache_replacement_policy
heap LFUDA
memory_replacement_policy heap GDSF
memory_replacement_policy heap GDSF
Idealnya
ruang di hardisk yg anda pakai hanya sekitar 70% dari total krn semakin penuh
Squid akan semakin pelan mencari tempat kosong, mis. utk cache 1 GB maka yg
dipakai hanya 700MB (jangan 1GB dipakai semuanya). Jangan lupa hanya 1
direktori per drive krn faktor penghambat adalah kecepatan spindle hardisk lho,
bukan terus dg memperbanyak direktori pada 1 hd akan mempercepat (hd orde
milidetik, memori orde nanodetik). Jadi mending hardisknya banyak tapi
ukurannya kecil-kecil daripada hanya 1 berukuran besar. Terus jika OS-nya Linux
pakailah FS-nya Reiser (versi 4 tercepat) dg metode akses aufs. Diskd optimal
di FreeBSD tetapi tidak di Linux lho. Jangan lupa di partisi tsb noatime dan
notail diaktifkan spy tidak menambah ekstra write saat menulis atau membaca.
Intinya hardisk adalah faktor penghambat terbesar di Squid.
saran
kira2 70% dari 16GB
cache_dir
aufs /cachez 12000 28 256
atau
(utk ruang 4GB-an per hardisk)
cache_dir
aufs /cachehardisk1 3000 8 256
cache_dir aufs /cachehardisk2 3000 8 256
cache_dir aufs /cachehardisk3 3000 8 256
cache_dir aufs /cachehardisk4 3000 8 256
cache_dir aufs /cachehardisk2 3000 8 256
cache_dir aufs /cachehardisk3 3000 8 256
cache_dir aufs /cachehardisk4 3000 8 256
Logging
untuk info yg vital saja dan diusahakan file-file log ada di hardisk tersendiri
spy tidak mempengaruhi kecepatan direktori cache utamanya.
log_fqdn
off
log_icp_queries off
cache_log none
cache_store_log none
log_icp_queries off
cache_log none
cache_store_log none
Dengan
memaksa sedikit supaya akses obyek lebih intensif di lokal Squid dan waktu
simpan ditambah sebelum proses validasi terjadi (mis. validasi terjadi per 3
jam dg penyimpanan obyek terlama 3 bulan, utk ftp bisa lebih lama lagi).
refresh_pattern
^ftp: 10080 95% 241920 reload-into-ims override-lastmod
refresh_pattern . 180 95% 120960 reload-into-ims override-lastmod
refresh_pattern . 180 95% 120960 reload-into-ims override-lastmod
Toleransi
aborting dihilangkan saja.
quick_abort_min
0
quick_abort_max 0
quick_abort_pct 98
quick_abort_max 0
quick_abort_pct 98
Mematikan
dan merekonfigurasi Squid jangan terlalu cepat krn bisa mengakibatkan
integritas file kacau.
shutdown_lifetime
10 seconds
Tidak
perlu reservasi memori.
memory_pools
off
Penting
utk relasi dg sibling dg mengukur respons-nya via ICP dan ICMP.
icp_hit_stale
on
query_icmp on
query_icmp on
Penting
utk meningkatkan refresh pattern lebih lanjut.
reload_into_ims
on
pipeline_prefetch on
vary_ignore_expire on
pipeline_prefetch on
vary_ignore_expire on
Sekali
lagi Squid diperlukan utk mengambil yg jaraknya jauh, jarak dekat langsung saja
acl
local-dst dst semuaalamatlokal semuaalamatipygdekat
acl local-domain dstdomain localhost domain-anda.com isp-anda.com domainku.web.id
acl local-domain dstdomain localhost domain-anda.com isp-anda.com domainku.web.id
always_direct
allow localhost local-dst local-domain
always_direct deny all
always_direct deny all
Sys-V
init squid :
root@proxy
root# vi /etc/init.d/squid
#!/bin/bash
# squid This shell script takes care of starting and stopping
# Squid Internet Object Cache
#
# chkconfig: – 90 25
# description: Squid – Internet Object Cache. Internet object caching is \
# a way to store requested Internet objects (i.e., data available \
# via the HTTP, FTP, and gopher protocols) on a system closer to the \
# requesting site than to the source. Web browsers can then use the \
# local Squid cache as a proxy HTTP server, reducing access time as \
# well as bandwidth consumption.
# pidfile: /var/run/squid.pid
# config: /etc/squid/squid.conf
# squid This shell script takes care of starting and stopping
# Squid Internet Object Cache
#
# chkconfig: – 90 25
# description: Squid – Internet Object Cache. Internet object caching is \
# a way to store requested Internet objects (i.e., data available \
# via the HTTP, FTP, and gopher protocols) on a system closer to the \
# requesting site than to the source. Web browsers can then use the \
# local Squid cache as a proxy HTTP server, reducing access time as \
# well as bandwidth consumption.
# pidfile: /var/run/squid.pid
# config: /etc/squid/squid.conf
PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH
export PATH
#
Source function library.
. /etc/rc.d/init.d/functions
. /etc/rc.d/init.d/functions
#
Source networking configuration.
. /etc/sysconfig/network
. /etc/sysconfig/network
#
Check that networking is up.
[ ${NETWORKING} = “no” ] && exit 0
[ ${NETWORKING} = “no” ] && exit 0
#
check if the squid conf file is present
[ -f /etc/squid/squid.conf ] || exit 0
[ -f /etc/squid/squid.conf ] || exit 0
if
[ -f /etc/sysconfig/squid ]; then
. /etc/sysconfig/squid
fi
. /etc/sysconfig/squid
fi
#
don’t raise an error if the config file is incomplete
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-”-DY”}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-”-DY”}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
#
determine the name of the squid binary
[ -f /usr/sbin/squid ] && SQUID=squid
[ -z “$SQUID” ] && exit 0
[ -f /usr/sbin/squid ] && SQUID=squid
[ -z “$SQUID” ] && exit 0
prog=”$SQUID”
#
determine which one is the cache_swap directory
CACHE_SWAP=`sed -e ’s/#.*//g’ /etc/squid/squid.conf | \
grep cache_dir | awk ‘{ print $3 }’`
[ -z “$CACHE_SWAP” ]
CACHE_SWAP=`sed -e ’s/#.*//g’ /etc/squid/squid.conf | \
grep cache_dir | awk ‘{ print $3 }’`
[ -z “$CACHE_SWAP” ]
RETVAL=0
start()
{
for adir in $CACHE_SWAP; do
if [ ! -d $adir/00 ]; then
echo -n “init_cache_dir $adir… “
$SQUID -z -F -D >> /var/log/squid/squid.out 2>&1
fi
done
echo -n $”Starting $prog: “
ulimit -HSn 2048
/bin/nice –20 $SQUID $SQUID_OPTS >> /var/log/squid/squid.out 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
timeout=0;
while : ; do
[ ! -f /var/run/squid.pid ] || break
if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
RETVAL=1
break
fi
sleep 1 && echo -n “.”
timeout=$((timeout+1))
done
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SQUID
[ $RETVAL -eq 0 ] && echo_success
[ $RETVAL -ne 0 ] && echo_failure
echo
return $RETVAL
}
for adir in $CACHE_SWAP; do
if [ ! -d $adir/00 ]; then
echo -n “init_cache_dir $adir… “
$SQUID -z -F -D >> /var/log/squid/squid.out 2>&1
fi
done
echo -n $”Starting $prog: “
ulimit -HSn 2048
/bin/nice –20 $SQUID $SQUID_OPTS >> /var/log/squid/squid.out 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
timeout=0;
while : ; do
[ ! -f /var/run/squid.pid ] || break
if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
RETVAL=1
break
fi
sleep 1 && echo -n “.”
timeout=$((timeout+1))
done
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SQUID
[ $RETVAL -eq 0 ] && echo_success
[ $RETVAL -ne 0 ] && echo_failure
echo
return $RETVAL
}
stop()
{
echo -n $”Stopping $prog: “
$SQUID -k check >> /var/log/squid/squid.out 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
$SQUID -k shutdown &
rm -f /var/lock/subsys/$SQUID
timeout=0
while : ; do
[ -f /var/run/squid.pid ] || break
if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
echo
return 1
fi
sleep 2 && echo -n “.”
timeout=$((timeout+2))
done
echo_success
echo
else
echo_failure
echo
fi
return $RETVAL
}
echo -n $”Stopping $prog: “
$SQUID -k check >> /var/log/squid/squid.out 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
$SQUID -k shutdown &
rm -f /var/lock/subsys/$SQUID
timeout=0
while : ; do
[ -f /var/run/squid.pid ] || break
if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
echo
return 1
fi
sleep 2 && echo -n “.”
timeout=$((timeout+2))
done
echo_success
echo
else
echo_failure
echo
fi
return $RETVAL
}
reload()
{
$SQUID $SQUID_OPTS -k reconfigure
}
$SQUID $SQUID_OPTS -k reconfigure
}
restart()
{
stop
start
}
stop
start
}
condrestart()
{
[ -e /var/lock/subsys/squid ] && restart || :
}
[ -e /var/lock/subsys/squid ] && restart || :
}
rhstatus()
{
status $SQUID
$SQUID -k check
}
status $SQUID
$SQUID -k check
}
probe()
{
return 0
}
return 0
}
case
“$1″ in
start)
start
;;
start)
start
;;
stop)
stop
;;
stop
;;
reload)
reload
;;
reload
;;
restart)
restart
;;
restart
;;
condrestart)
condrestart
;;
condrestart
;;
status)
rhstatus
;;
rhstatus
;;
probe)
exit 0
;;
exit 0
;;
*)
echo $”Usage: $0 {start|stop|status|reload|restart|condrestart}”
exit 1
esac
echo $”Usage: $0 {start|stop|status|reload|restart|condrestart}”
exit 1
esac
exit
$?
4.
Paramater lain Tunning System Squid :
Edit
di /etc/sysctl.conf, dan tambahkan di bawah ini:
root@proxy
root# vi /etc/sysctl.conf
# add port outgoing
net.ipv4.ip_local_port_range = 1024 32768
# add port outgoing
net.ipv4.ip_local_port_range = 1024 32768
Tunning
di fstab :
edit
di /etc/fstab, harusnya seperti ini yg harus sama yg di ubah (biasanya ada
tambahan noatime/notail, untuk jenis mounting yg lain biarkan saja, jangan
diubah):
/dev/hda1
/ reiserfs defaults,noatime 1 1
/dev/hda6 /boot reiserfs defaults,noatime 1 2
/dev/hda7 /var reiserfs defaults,noatime 1 2
/dev/hda8 /usr reiserfs defaults,noatime 1 2
/dev/hda9 /home reiserfs defaults,noatime 1 2
/dev/sda1 /cache01 reiserfs noatime,notail 0 0
/dev/sda2 /cache02 reiserfs noatime,notail 0 0
/dev/sdb1 /cache03 reiserfs noatime,notail 0 0
/dev/sdb2 /cache04 reiserfs noatime,notail 0 0
/dev/hda6 /boot reiserfs defaults,noatime 1 2
/dev/hda7 /var reiserfs defaults,noatime 1 2
/dev/hda8 /usr reiserfs defaults,noatime 1 2
/dev/hda9 /home reiserfs defaults,noatime 1 2
/dev/sda1 /cache01 reiserfs noatime,notail 0 0
/dev/sda2 /cache02 reiserfs noatime,notail 0 0
/dev/sdb1 /cache03 reiserfs noatime,notail 0 0
/dev/sdb2 /cache04 reiserfs noatime,notail 0 0
Check
yg melakukan koneksi ke squid :
root@proxy
root# tail -f /var/log/squid/access.log
Daftar Pustaka
http://dedenthea.wordpress.com/2007/02/01/apa-itu-squid/
http://forum.linux.or.id (mas dani, fish,
fai, firewaxx, dan semua barudak forum.linux.or.id)http://www.squid-cache.org/Doc/FAQ/FAQ.html
http://aa.cakralintas.net.id/
http://dedenthea.wordpress.com/2007/02/01/apa-itu-squid/?like=1&_wpnonce=c227c5574e
Komentar
Posting Komentar