Nama:
Lokasi: Indonesia
Postingan Sebelumnya
Visit the Site

Powered by Blogger

MARVEL and SPIDER-MAN: TM & © 2007 Marvel Characters, Inc. Motion Picture © 2007 Columbia Pictures Industries, Inc. All Rights Reserved. © 2007 Sony Pictures Digital Inc. All rights reserved.
Instalasi Squid, Banner Filter, Porn Filter, Limit Bandwith, Transparan Proxy
Rabu, 28 Maret 2007 |
Dokumen ini ditujukan untuk membantu membuat sebuah proxy server. Sistem Operasi yang digunakan adalah Redhat Linux 7.2. Semua paket tersebut menggunakan format source tarball. Tidak ada copyright apapun dalam dukumen ini, anda bebas menyalin, mencetak, maupun memodifikasi (dengan menyertakan nama penulis asli). Saran, koreksi, kritik, kesalahan ketik, maupun ucapan silakan dikirimkan ke email tersebut diatas. Semoga bermanfaat dan memajukan opensource software di Indonesia.

Pastikan login pada server anda adalah sebagai root

1. Instalasi Banner Filter
Penempatan direktori Banner Filter harus didalam direktori www kita. misal saya di /usr/local/apache/htdocs .download souce Banner Filter di http://phroggy.com/files/unix/bannerfilter-1.21.tar.gz

[root@PROXY hanny]# wget http://phroggy.com/files/unix/bannerfilter-1.21.tar.gz

Ekstrak source bannerfilter-1.21.tar.gz :
[root@PROXY hanny]# tar -xzvf bannerfilter-1.21.tar.gz

Kemudian pindahkan hasil exstrak
bannerfilter-1.21.tar.gz ke dalam /usr/local/apache/htdocs
[root@PROXY hanny]# mv bannerfilter-1.21 /usr/local/apache/htdocs/bannerfilter
[root@PROXY hanny]# cd /usr/local/apache/htdocs/bannerfilter

Edit file
bannerfilter.conf
[root@PROXY bannerfilter]# mv bannerfilter.conf /etc
[root@PROXY bannerfilter]# vi /etc/bannerfilter.conf

Contoh isi bannerfilter.conf saya :
# Path to the directory containing the data files:
$DATA='/usr/local/apache/htdocs/bannerfilter';

# URL of the directory containing the HTML and graphics files
# (this must be accessible by the machine running Squid; it does
# not need to be accessible to the client machines):
$WWW='http://www.rsds.or.id/bannerfilter/www';

# Path to the banner log file if you want one, or leave empty (if
# specified, Squid must have write access to this file):
$LOG='';

# $LOG='/tmp/bannerlog.txt';
# If you prefer not to see "Blocked", use null.gif instead of
# banner.gif:
$BANNERGIF='banner.gif';

Penambahan script bannerfilter nantinya akan diletakan didalam squid.conf
redirect_program /usr/local/apache/htdocs/bannerfilter/redirector.pl


2. Instalasi Squid
Sebelum installasi squid, pastikan daemon squid yang asli dari redhat harus anda stop atau musnahkan !!
caranya :
[root@PROXY hanny]# /etc/rc.d/init.d/squid stop
[root@PROXY hanny]# for a in `rpm -qa | grep squid`; do rpm -e --nodeps $a; done

Sekarang kita mendownload source squid. Saya menggunakan squid-2.5.STABLE2
Download source squid di http://www.squid-cache.org/Versions/v2/2.5/squid-2.5.STABLE2.tar.gz

[root@PROXY hanny]# wget http://www.squid-cache.org/Versions/v2/2.5/squid-2.5.STABLE2.tar.gz

Ekstrak source squid-2.5.STABLE2.tar.gz :
[root@PROXY hanny]# tar -xzvf squid-2.5.STABLE2.tar.gz
[root@PROXY hanny]# cd squid-2.5.STABLE2

Buat user untuk menjalankan squid, nama usernya adalah squid
Guna meningkatkan keamanan server kita, maka user squid tidak bisa digunakan untuk login
[root@PROXY squid-2.5.STABLE2]# useradd -d /usr/local/squid/ -r -s /dev/null squid > /dev/null 2>&1

Kompilasi dan install Squid :
[root@PROXY squid-2.5.STABLE2]# ./configure --prefix=/usr/local/squid --exec-prefix=/usr/local/squid \
> --enable-delay-pools --enable-cache-diggests --enable-poll \
> --disable-ident-lookups --enable-async-io=16 \
> --enable-auth-modules --enable-removal-policies --enable-snmp

[root@PROXY squid-2.5.STABLE2]# make all
Biasanya proses make all ini berlangsung lama

[root@PROXY squid-2.5.STABLE2]# make install

Sekarang kita masuk dalam tahap meng-edit konfigurasi ke dalam file
squid.conf
[root@PROXY squid-2.5.STABLE2]# cd /usr/local/squid/etc

Anda bisa membaca terlebih dahulu http://www.squid-cache.org/Doc/FAQ/FAQ.html
Dalam meng-edit konfigurasi squid, anda bisa membaca readme yang sudah ada di dalam file squid.conf atau anda juga bisa melihat atau mengambil, file yang sudah saya edit http://www.rsds.or.id/linux/squid.conf.hanny

[root@PROXY etc]# wget http://www.rsds.or.id/linux/squid.conf.hanny
[root@PROXY etc]# vi squid.conf.hanny

kemudian carilah kata-kata dalam file squid.conf.hanny seperti keterangan dibawah ini yang berhurup bold italic :
ftp_user name@domain-anda.com
dns_nameservers IP-Address-DNS-ISP-Anda
acl user src 192.168.0.0/255.255.255.0
(ip192.168.0.0 adalah ranges ip address client kita mulai 192.168.0.0 sampai 192.168.0.255)

Didalam file squid.conf.hanny, sudah saya tambahkan script untuk menjalankan Banner Filter dan Porn Filter :
redirect_program /usr/local/apache/htdocs/bannerfilter/redirector.pl
acl porn url_regex "/usr/local/squid/etc/porn.txt"
http_access deny porn


"Jika anda tidak menginginkan Banner Filter atau Porn Filter berjalan, maka pada awal script Banner Filter atau Porn Filter dalam file squid.conf.hanny harus di beri tanda " # " :
#redirect_program /usr/local/apache/htdocs/bannerfilter/redirector.pl
#acl porn url_regex "/usr/local/squid/etc/porn.txt"
#http_access deny porn



3. Limit Bandwith

Dalam file squid.conf.hanny, juga sudah saya tambahkan script untuk menggunakan delay pool :

#------------------------ DELAY POLL KONFIGURASI HANNY ---------------------------
#This is the most important part for shaping incoming traffic with Squid
#For detailed description see squid.conf file or docs at http://www.squid-cache.org
#We don't want to limit downloads on our local network
acl magic_words1 url_regex -i 192.168.
#We want to limit downloads of these type of files
#Put this all in one line
acl magic_words2 url_regex -i ftp .exe .mp3 .vqf .tar.gz .gz .rpm .zip .rar .avi .mpeg .mpe .mpg .qt .ram .rm .iso .raw .wav
#We don't block .html, .gif, .jpg and similar files, because they
#generally don't consume much bandwith
#We have two different delay_pools
delay_pools 2
#First delay pool
#W don't want to delay our local traffic
#There are three pool classes; here we will deal only with the second
delay_class 1 2
#-1/-1 mean that there are no limits
delay_parameters 1 -1/-1 -1/-1
#magic_words1: 192.168
delay_access 1 allow magic_words1
#Second delay pool
#we want to delay downloading files mentioned in magic_words2
delay_class 2 2
#The numbers here are values in bytes;
#we must remember that Squid doesn't consider start/stop bits
#5000/150000 are values for the whole network
#5000/120000 are values for the single IP
#after downloaded files exceed about 150000 bytes,
#(or even twice or three times as much)
#they will continue to download at about 5000 bytes/s
delay_parameters 2 5000/150000 5000/120000
delay_access 2 allow magic_words2
#--------------------------------------------------------------------------------

"Jika anda tidak menginginkan Limit Bandwith berjalan, maka pada awal script delay poll dalam file squid.conf.hanny harus diberi tanda " # "
#------------------------ DELAY POLL KONFIGURASI HANNY ---------------------------
#This is the most important part for shaping incoming traffic with Squid
#For detailed description see squid.conf file or docs at http://www.squid-cache.org
#We don't want to limit downloads on our local network
#acl magic_words1 url_regex -i 192.168.
#We want to limit downloads of these type of files
#Put this all in one line
acl magic_words2 url_regex -i ftp .exe .mp3 .vqf .tar.gz .gz .rpm .zip .rar .avi .mpeg .mpe .mpg .qt .ram .rm .iso .raw .wav
#We don't block .html, .gif, .jpg and similar files, because they
#generally don't consume much bandwith
#We have two different delay_pools
#delay_pools 2
#First delay pool
#W don't want to delay our local traffic
#There are three pool classes; here we will deal only with the second
#delay_class 1 2
#-1/-1 mean that there are no limits
#delay_parameters 1 -1/-1 -1/-1
#magic_words1: 192.168
#delay_access 1 allow magic_words1
#Second delay pool
#we want to delay downloading files mentioned in magic_words2
#delay_class 2 2
#The numbers here are values in bytes;
#we must remember that Squid doesn't consider start/stop bits
#5000/150000 are values for the whole network
#5000/120000 are values for the single IP
#after downloaded files exceed about 150000 bytes,
#(or even twice or three times as much)
#they will continue to download at about 5000 bytes/s
#delay_parameters 2 5000/150000 5000/120000
#delay_access 2 allow magic_words2
#--------------------------------------------------------------------------------


Merubah nama file squid..conf yang asli dari komputer anda ke nama file lain. (sebagai back-up)
Dan merubah squid.conf.hanny menjadi squid.conf
[root@PROXY etc]# mv squid.conf squid.conf.punyaku
[root@PROXY etc]# mv squid.conf.hanny squid.conf


4. Instalasi Porn Filter
Buatlah terlebih dahulu file dengan nama porn.txt
[root@PROXY etc]# touch porn.txt

Isikan file porn.txt dengan site-site yang hendak anda tutup, misal www.17tahun.com
[root@PROXY etc]# vi porn.txt
isikan dengan kata 17tahun


Menjalankan squid

Memberi hak direktori squid dan bannerfilter agar proses berjalan lancar :
[root@PROXY etc]# chown -R squid.squid /usr/local/squid
[root@PROXY etc]# chown -R squid.squid /usr/local/apache/htdocs/bannerfilter

Aktifkan cache squid anda terlebih dahulu:
[root@PROXY etc]# /usr/local/squid/sbin/squid -z

Jika muncul permission denied pada saat pembuatan cache, cek dulu owner dan permission untuk directory cache :
[root@PROXY etc]# chmod 777 /usr/local/squid/var/logs/

Sampai tahap ini jika ada pesan error mohon email ke hanny@rsds.or.id

Jalankan daemon squid anda :
[root@PROXY etc]# /usr/local/squid/sbin/squid

Cek squid anda apakah jalan atau tidak :
[root@PROXY etc]# netstat -pln | grep squid
tcp 0 0 0.0.0.0 :8080 0.0.0.0:* LISTEN 777/(squid)
udp 0 0 0.0.0.0 :32771 0.0.0.0:* 777/(squid)
udp 0 0 0.0.0.0 :3130 0.0.0.0:* 777/(squid)


Test Squid Dari Komputer Client
Lakukan penge-test ping antar network anda, misal server anda mempunyai ip 192.168.0.1 dan ip windows client anda 192.168.1.2 :
[root@PROXY etc]# ping 192.168.0.2
PING 192.168.0.2 (192.168.0.2) from 192.168.0.1 : 56(84) bytes of data.
Warning: time of day goes back, taking countermeasures.
64 bytes from 192.168.0.2: icmp_seq=0 ttl=255 time=233 usec
64 bytes from 192.168.0.2: icmp_seq=1 ttl=255 time=161 usec

Jika anda mempunyai client dengan operating system windows 98 atau windows me atau windows XP, pada software internet explorer coba isikan proxy dengan ip server anda dan port 8080 (misal ip server saya 192.168.0.1 maka pengisian proxy adalah 192.168.0.1 : 8080)

Coba anda buka situs-situs berikut ini dalam masing-masing new windows internet explorer :
http://www.yahoo.com , http://www.17tahun.com , http://zdads.e-media.com

1. Bila situs http://www.yahoo.com terbuka maka artinya pengerjaan squid anda sampai tahap ini berjalan lancar.

2. Bila situs http://www.17tahun.com tidak terbuka dan hanya bertulisakan ACCESS DENIED maka Porn Firter anda berjalan lancar. Anda bisa menambahkan situs-situs yang ingin anda tutup, dengan meng-edit kembali file porn.txt
[root@PROXY hanny]# vi /usr/local/squid/etc/porn.txt

3. Bila situs http://
zdads.e-media.com tidak berbuka dan hanya bergambar BLOCKED AREA maka Banner Filter anda berjalan lancar.


5. Transparan Proxy
Agar lebih mudah kita akan menggunakan iptables
[root@PROXY hanny]# /sbin/iptables -F -t nat
[root@PROXY hanny]# /sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp -s 192.168.0.0/255.255.255.0 \
> --dport 80 -j DNAT --to 192.168.0.1:8080

keterangan iptables diatas :
1. eth1 adalah interface lancard untuk ip gateway client.
2. 192.168.0.0/255.255.255.0 adalah ip client kita mulai dari 192.168.0.0 sampai 192.168.0.255.
3. --dport 80 -j DNAT --to 192.168.0.1:8080 adalah bila ada request port 80 (biasanya browsing), akan di paksa masuk ke squid dengan ip 192.168.0.1 port 8080.

Jika anda mempunyai client dengan operating system windows 98 atau windows me atau windows XP, pada software internet explorer, pastikan tidak terisi proxy. Dan pastikan pengisian ip client dan ip gateway client anda adalah benar adanya !!!
(Misal ip client saya mempunyai ip 192.168.0.2 dan ip gateway 192.168.0.1)

Coba anda buka situs-situs berikut ini dalam masing-masing new windows internet explorer :
http://www.yahoo.com , http://www.17tahun.com , http://zdads.e-media.com

1. Bila situs http://www.yahoo.com terbuka maka artinya pengerjaan squid anda sampai tahap ini berjalan lancar.

2. Bila situs http://www.17tahun.com tidak terbuka dan hanya bertulisakan ACCESS DENIED maka Porn Firter anda berjalan lancar. Anda bisa menambahkan situs-situs yang ingin anda tutup, dengan meng-edit kembali file porn.txt
[root@PROXY hanny]# vi /usr/local/squid/etc/porn.txt

3. Bila situs http://
zdads.e-media.com tidak berbuka dan hanya bergambar BLOCKED AREA maka Banner Filter anda berjalan lancar.



Autorun Squid dan Transparan Proxy
Bila server squid kita restart dan kita tidak ingin mengulangi command2x seperti hal-hal pada artikel di atas, maka masukan script pada /etc/rc.local :
[root@PROXY hanny]# vi /etc/rc.local

isikan dengan :
#Menjalankan Transparan Proxy
/sbin/iptables -F -t nat

/sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp -s 192.168.0.0/255.255.255.0 --dport 80 -j DNAT --to 192.168.0.1:8080


#Menghidupkan Squid
/bin/rm /usr/local/squid/var/logs/squid.pid
/usr/local/squid/sbin/squid



6. Lain-Lain
Bila kita inggin melihat siapa saja yang sedang mengunakan squid kita dan situs-situs apa saja yang mereka buka, anda bisa menggunakan:
[root@PROXY hanny]# tail -f /usr/local/squid/var/logs/access.log

Bila anda merubah isi file squid.conf dan ingin mencoba apakah squid.conf yang kita rubah bisa sesuai yang kita inginkan :
[root@PROXY hanny]# /usr/local/squid/sbin/squid -k reconfigure


7. ChangeLog
24 Maret 2003
Penambahan
permission pada direktory cache (dani@bisnisweb.com)

24 Maret 2003
Penulisan tutorial ini dimulai (hanny@rsds.or.id)


8. Referensi
1. http://www.squid-cache.org/
2. http://www.tldp.org/HOWTO/mini/TransparentProxy.html
3. http://jateng.linux.or.id/index.html
4. http://netfilter.samba.org/
5. http://phroggy.com/bannerfilter/


9. Ucapan Terima Kasih
Hanny Wijaya (hanny@rsds.or.id)

diposting oleh palzum @ 08.50

1 Komentar:

  • Pada 17 Juli, 2008 , Anonymous Anonim mengatakan...

    apaan neh artikel orang masih aja di reposting!menuhin conten ajah..buang2 bandwith!

     

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda