EKAKJ

November 12, 2007

Proxy Server Ubuntu #1

Filed under: linux — ekakj @ 4:07 pm

Panduan ini akan terdiri dari beberapa bagian :

  1. Setup manual proxy
  2. Setup transparent proxy
  3. Firewalling

Uji coba dilakukan dengan mesin P3 600, RAM 128 MB dan distro Ubuntu Server 7.04. Jika uji coba ini diterapkan secara real dengan user yang cukup besar akan lebih baik jika hardware menggunakan spek yang lebih tinggi.

Asumsi :

eth0 : 10.25.10.250
eth1 : 192.168.0.250

$ sudo vim /etc/network/interfaces
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 10.25.10.250
netmask 255.255.255.0
network 10.25.10.0
broadcast 10.25.10.255
gateway 10.25.10.3

auto eth1
iface eth1 inet static
address 192.168.0.250
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

Asumsi diatas adalah semua iface menggunakan ip lokal namun jika menggunakan ip publik langsung saja ganti iface eth0 dengan ip publik.

Bagian #1 – Manual Proxy

Instal squid, mulai dari Ubuntu 6.10 Squid 2.5 sudah digantikan dengan Squid 2.6 dan akan ada sedikit perbedaan konfigurasi khususnya pada bagian transparent proxy.

$ sudo apt-get install squid

Lakukan filter terhadap komentar yang ada di squid.conf.

$ sudo cat /etc/squid/squid.conf | sed ‘/ *#/d; /^ *$/d’ >/etc/squid/squid.conf.bak

$ sudo cat /etc/squid/squid.conf.bak > /etc/squid/squid.conf

Konfigurasi squid dengan menambahkan baris yang berhuruf tebal.

$ sudo vim /etc/squid/squid.conf
http_port 3128
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
access_log /var/log/squid/access.log squid
hosts_file /etc/hosts
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320

acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
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 Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
acl myLAN src 192.168.0.0/24
http_access allow myLAN

http_access deny all
http_reply_access allow all
icp_access allow all
visible_hostname http://www.slc.web.id
cache_effective_group proxy
coredump_dir /var/spool/squid

Jika squid sudah di konfigurasi dengan benar, maka jika service squid di restart akan tampak seperti dibawah ini.

$ sudo /etc/init.d/squid restart
* Restarting Squid HTTP proxy squid * Creating squid spool directory structure
2004/08/28 11:04:00| Creating Swap Directories
[ OK ]

Selanjutnya set proxy di browser client ke alamat 192.168.0.250 dengan port 3128, dan lakukan browsing. Kemudian cek log squid, jika terdapat log seperti dibawah ini berarti squid sudah berjalan normal.

$ sudo tail -f /var/log/squid/access.log
1188188452.488 1390 192.168.0.230 TCP_MISS/301 562 GET http://google.com/ – DIRECT/72.14.207.99 text/html
1188188454.549 2042 192.168.0.230 TCP_MISS/302 552 GET http://www.google.com/ – DIRECT/64.233.189.104 text/html
1188188456.078 1515 192.168.0.230 TCP_MISS/200 1684 GET http://www.google.co.id/ – DIRECT/64.233.189.104 text/htm

Dari log diatas dapat dilihat bahwa client dengan ip address 192.168.0.230 sedang mengakses google.com. Sampai disini setup bagian #1 setup manual proxy selesai.

Share and Enjoy:

5 Comments »

  1. tanks

    Comment by sakkir — November 22, 2007 @ 3:03 am | Reply

  2. makasih yah.. tar di coba

    Comment by Oche — November 28, 2007 @ 4:05 pm | Reply

  3. bagaimana dengan setting Transparent proxy?

    Comment by sakkir — February 3, 2008 @ 7:25 am | Reply

  4. bagaimana dengan setting Transparent proxy?

    Comment by sakkir — February 3, 2008 @ 7:27 am | Reply

  5. Thanks artikelnya, coba lsg jalan

    Comment by demit — September 11, 2008 @ 1:57 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: