FBB Ubuntu Squid 2.7

kita update dulu
apt-get update
kemudian install pasukan – pasukanya berikut ini
apt-get install build-essential sharutils ccze libzip-dev automake1.9 gcc  squid squidclient squid-cgi
setelah itu kita Optimalisasi Squid Proxy server
1. Optimalkan file system cache & ubah opsi untuk partisi cache
Disabled fsck (file system check)
# nano /etc/fstab
Angka standart Drive Cache adalah 0 2 ——>> ganti dengan 0 0 (INGAT HANYA DRIVE CACHE)
Opsi Directory /cache :
Apabila menggunakan reiserfs gunakan opsi noatime,notail
Apabila menggunakan ext4 gunakan opsi noatime,barrier=0
Apabila menggunakan btrfs gunakan opsi noatime,compress,noacl
Setelah selesai tekan Ctrl+O, lalu Enter untuk Save dan Ctrl+X untuk exit
2. Optimalkan kernelnya :
# ulimit -HSn 65536
echo 65536 > /proc/sys/fs/file-max
echo “* soft nofile 65536″ >> /etc/security/limits.conf
echo “* hard nofile 65536″ >> /etc/security/limits.conf
echo “root soft nofile 65536″ >> /etc/security/limits.conf
echo “root hard nofile 65536″ >> /etc/security/limits.conf
echo “proxy soft nofile 65536″ >> /etc/security/limits.conf
echo “proxy hard nofile 65536″ >> /etc/security/limits.conf
rapikan opsi diatas, pindahkan diatas tulisan ‘exit=0, caranya :
# nano /etc/security/limits.conf
Setelah selesai tekan Ctrl+O, lalu Enter untuk Save dan Ctrl+X untuk exit
Masukkan perintah berikut :
echo “session required pam_limits.so” >> /etc/pam.d/common-session
echo “session required /lib/security/pam_limits.so” >> /etc/pam.d/login
Jika terjadi error login (saat proxy server direstart nanti) hapus kembali opsi :
session required /lib/security/pam_limits.so
dengan mengetikan perintah :
# nano /etc/pam.d/login
Cari pada baris paling bawah tulisan “session required /lib/security/pam_limits.so”, lalu hapus.
Setelah selesai tekan Ctrl+O, lalu Enter untuk Save dan Ctrl+X untuk exit (INGAT HANYA DILAKUKAN JIKA TERJADI ERROR LOGIN SETELAH RESTART PROXY NANTI, JIKA TIDAK ERROR JANGAN DIJALANKAN PERINTAH DIATAS)
# modprobe ip_conntrack
kemudian tambahkan ip_contrack di /etc/modules
# nano /etc/modules
tambahkan kalimat berikut baris paling bawah :
ip_conntrack
Setelah selesai tekan Ctrl+O, lalu Enter untuk Save dan Ctrl+X untuk exit
1. Optimalkan dahulu opsi berikut ini sebelum proses compile :
# nano /etc/default/squid
Ubah opsi SQUID_MAXFD=1024 menjadi :
SQUID_MAXFD=8192
Ubah opsi #define __FD_SETSIZE 1024 dengan mengetik perintah berikut :
# nano /usr/include/linux/posix_types.h
Cari tulisan #define __FD_SETSIZE 1024 ubah menjadi #define __FD_SETSIZE 65536
Setelah selesai tekan Ctrl+O, lalu Enter untuk Save dan Ctrl+X untuk exit
Cari tulisan #define __FD_SETSIZE 1024 dengan mengetik perintah berikut :
# nano /usr/include/bits/typesizes.h
Cari tulisan #define __FD_SETSIZE 1024 ubah menjadi #define __FD_SETSIZE 65536
Opsi-opsi diatas nanti (JANGAN DICEK DULU) akan terlihat hasilnya pada pada saat kita melakukan perintah :
# squidclient mgr:info
Maka :
Maximum number of file descriptors: 1024
Akan terlihat menjadi :
Maximum number of file descriptors: 65536
3. download squid yang sudah di pacth
wget http://tempat-sampah.googlecode.com/files/squid-2.7.STABLE9%2Bpatch.tar.gz
lalu ekstrak :masuk ke foldernya :
# tar xvf squid-2.7.STABLE9+patch.tar.gz
# cd squid-2.7.STABLE9
4. ok..!! sekarang dimulai tahap compile nya :
cat /proc/cpuinfo : untuk mengetahui info cpu proxy nya dan sesuaikan dengan processor yang anda pakai
Link untuk mengetahui CHOST dan CFLAGS ;
# untuk AMD http://en.gentoo-wiki.com/wiki/Safe_Cflags/AMD
# untuk INTEL http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
CHOST=”i686-pc-linux-gnu” \
CFLAGS=”-march=pentium4 -O2 -pipe -fomit-frame-pointer” \
./configure \
-prefix=/usr \
-enable-async-io \
-enable-useragent-log \
-enable-snmp \
-enable-cache-digests \
-enable-follow-x-forwarded-for \
-enable-storeio=”aufs” \
-enable-removal-policies=”heap,lru” \
-with-maxfd=16384 \
-enable-delay-pools \
-enable-poll \
-disable-ident-lookups \
-enable-truncate \
-exec-prefix=/usr \
-bindir=/usr/sbin \
-libexecdir=/usr/lib/squid
penjelasan :
Nilai CHOST dan CFLAGS berbeda tergantung dari jenis prosesor mesin anda. Ganti opsi ini sesuai dengan prosesor yang anda gunakan. Untuk mengetahui nilai CHOST dan CFLAGS ketikkan perintah cat /proc/cpuinfo dan cocokkan dengan refensi nilai CHOST CFLAGS di halaman Gentoo Safe Cflags.
-enable-async-io: opsi ini untuk mengaktifkan asynchronous I/O – sangat penting untuk menghentikan squik melakukan blocking pada baca/tulis ke harddisk.
-enable-useragent-log berguna agar squid mencatat useragent di entri log – berguna jika anda menggunakan lynx untuk melakukan debug kecepatan squid.
-enable-snmp aktifkan ini jika anda ingin menampilkan statistik squid dalam bentuk grafik.
-enable-cache-digests harus diaktifkan jika anda menggunakan cache peer.
-enable-storeio=”aufs” adalah alernatif penyimanan metode I/O. AUFS adalah Asynchronous, memiliki performa yang signifikan ketimbang UFS atau diskd.
-enable-removal-policies=”heap,lru” adalah pilihan opsi untuk removal policies, dan saya memilih menggunakan “heap LFUDA”, atau anda juga bisa menggunakan “LRU”.
-with-maxfd=16384 digunakan agar squid tidak terblokir apabila dalam keadaan load tinggi.
-enable-poll untuk meningkatkan performa squid.
-disable-ident-lookups menghentikan squid dari melihat ident di setiap koneksi, bisa juga untuk mencegah serangan DOS yang dapat mematikan squid server, yang biasanya dengan cara membuka ribuan koneksi.
-enable-truncate memerintahkan squid untuk selalu menggunakan truncate() ketimbang unlink() ketika menghapus file cache.
enable-delay-pools jika anda ingin mengatur bandwidth koneksi
selanjutnya, ketik perintah berikut di terminal ubuntu :
make && make install
tunggu sampai selesai…..
# stop dulu squidnya :
sudo /etc/init.d/squid stop
#copy file squid.conf, dan storeur.pl kedalam folder /etc/squid
Dan edit sesuai network juragan
sudo cp /home/proxyku/squid.conf /etc/squid
sudo cp /home/proxyku/storeurl.pl /etc/squid
5. Langkah selanjutnya
# Memberikan permission pada folder cache
chown proxy:proxy /cache
chmod 777 /cache
chown proxy:proxy /etc/squid/storeurl.pl
chmod 777 /etc/squid/storeurl.pl
# Membuat folder-folder swap/cache di dalam folder cache yang telah ditentukan dg perintah :
squid -f /etc/squid/squid.conf -z
# start squid
sudo /etc/init.d/squid start
Selesai untuk install squidnya
Tahap berikutnya kita  Install Squidmon :
# wget http://squidmon.googlecode.com/svn/trunk/squidmon.py
# chmod +x squidmon.py
untuk monitor squid :
# cat /var/log/squid/access.log | ./squidmon.py
# cat /var/log/squid/access.log | python squidmon.py
Selesai semuannya
refresh_pattern [-i] regex min percent max [options]
where min and max are time values in minutes and percent is a percentage figure. The options are:
* override-expire — ignores the expire header from the Web server.
* override-lastmod — ignores the last modified date header from the Web server.
* reload-into-ims — a reload request from a client is converted into an If-Modified-Since request.
* ignore-reload — a client’s no-cache or “reload from origin server” directive is ignored. The request can therefore be satisfied from the cache if available.
* ignore-no-cache — a no-cache directive from the Web server which makes an object non-cacheable is ignored.
* ignore-no-store — a no-store directive from the Web server which makes an object non-cacheable is ignored.
* ignore-private — a private directive from the Web server which makes an object non-cacheable is ignored.
* ignore-auth — objects requiring authorisation are non-cacheable. This option overrides this limitation.
* refresh-ims — a refresh request from a client is converted into an If-Modified-Since request.
* If there is no expire header for all objects whose names end in .gif or .GIF (that is, image files) then:
* if the age (that is how long the object has been on your cache server) is less than 1,440 minutes, then consider it fresh and serve it and stop
* else if the age is greater than 10,080 minutes, consider it stale and go to the origin server for a fresh copy and stop
* else if the age is in between the min and max values, use the lm-factor to determine freshness. lm-factor is the ratio of the age on your cache server to the period since creation or modification of the object on the origin server as a percentage. So if the object was created 10,000 minutes ago on the origin server and it has been on my cache server for 1,800 minutes (that is the age) the lm-factor is 1,800/10,000 = 18%.
* If the lm factor is less than the percent in our refresh pattern (20%) then the object is considered fresh; serve it and stop
* else the object is stale, go for a fresh copy from the origin server.
Regex Cheat Sheet
Urutan Khusus
-          \d – untuk seluruh karakter berupa angka, sama seperti [0-9]
-          \D – untuk seluruh karakter yang bukan angka, sama seperti [^0-9]
-          \s – untuk karakter whitespace, sama seperti penulisan [\t\r\n\f\v]
-          \S – untuk karakter nonwhitespace, sama seperti penulisan [^\t\r\n\f\v]
-          \w – untuk semua karakter alpha numeric, yaitu alfabet dan angka, sama seperti [a-Za-Z0-9_]
-          \W – untuk semua karakter nonalphanumeric, sama seperti [^a-Za-Z0-9]
-          Titik – untuk semua karakter selain newline
Meta Characters
-          ^ – awal string
-          $ – akhir string
-          [ - pembuka untuk definisi kelas karakter
-          ] – penutup untuk definisi kelas karakter
-          | – alternatif, contohnya (a|b) berarti a atau b
-          ( – pembuka subpattern
-          ) – penutup subpattern
-          \ - escape character
Quantifiers
-          n* – nol atau lebih karakter n
-          n+ – satu atau lebih karakter n
-          n? – nol atau satu karakter n
-          (n) – perulangan tepat n kali
-          (n,) – perulangan minimal n kali
-          (n,m) – perulangan antara n sampai m kali
Pattern Modifiers
-          i – case insensitivie
-          m – Multiline mode – ^ dan $ untuk awal dan akhir baris
-          s – untuk menyertakan new line dalam pola
-          x – untuk regex dengan komentar dan whitespace
-          e – untuk evaluasi kode PHP (khusus fungsi preg_replace)
-          S – analisis tambahan terhadap pola
-          U – pencarian regex dengan metode ungreedy
-          U – pola dianggap sebaagi format UTF-8
Point based assertions
-          \b – word boundary
-          \B – bukan karakter word boundary
-          \A – awal subject
-          \Z – akhir subject atau karakter new line
-          \z – akhir subject
-          \G – posisi yang sesuai di awal subject
Assertions
-          (?=) – Mengecek setelah kata yang dicari foo (?=bar) akan mencari “foo” yang diikuti bar
-          (?!) – mengecek setelah kata yang dicari, tetapi bernilai negatif, foo (?!bar) akan menari foo yang tidak diikuti bar
-          (? – mengecek sebelum kata yang dicari (?
-          (? – mengecek sebelum kata yang dicari tetapi bernilai negatif, (?
-          (?>) – hanya satu subpattern, (?>\d+) bar
-          (?(x)) – subpatterns kondisional
-          (?(3)foo|fu)bar – mencari foo jika subpattern ketiga sesuai,jika tidak maka fu
-          (?#) – komentar (?# pattern does x y or z)
sumber : http://www.facebook.com/groups/333601510014970/doc/345523885489399/

Tidak ada komentar:

Posting Komentar