Proxy Server Linux dengan Squid

On June 18, 2007, in Linux, Networking, Server, by FX. Eko Budi Kristanto - 55,090 views
Proxy Server LinuxBagi sebagian rekan-rekan yang mau membuat proxy server dengan Linux, atau bagi adik-adik Ilmu Komputer USD yang mau coba-coba belajar bikin proxy, saya ingin membagikan pengalaman kecil saya dalam membuat proxy menggunakan Linux. Meski banyak software untuk membuat proxy server, saya memilih squid karena paketnya sudah ter-include dalam distro yang saya gunakan (Fedora Core) dan hampir sebagian proxy server Linux menggunakan squid. Untuk spesifikasi hardware yang saya gunakan, dapat dilihat di artikel Proxy Server di tempat kerja saya. Proxy server tersebut menggunakan squid versi 2.6-12 pada distro Fedora Core 6 yang saya fungsikan sebagai:
  1. Menyimpan halaman web di proxy untuk mempercepat akses Internet.
  2. Akses kontrol Internet berdasarkan IP Address. Menggunakan 2 network yang berbeda (saya fungsikan juga sebagai router – dengan IP Forwarding), untuk ini, saya menggunakan 3 NIC pada 1 server.
  3. Blacklist daftar situs terlarang secara manual.
  4. Membatasi ukuran download File dengan ekstension tertentu dan hanya berlaku pada jam tertentu.
  5. Pesan Error dalam format Bahasa Indonesia.
  6. Rule untuk memperbolehkan akses Internet hanya protokol tertentu saja.
Langkah-langkah yang saya lakukan:
  1. Instal aplikasi squid
  2. Edit file konfigurasi squid
  3. Buat direktori dan file blacklist untuk blacklist secara manual
  4. Buat direktori dan file untuk pesan error dalam bahasa indonesia
  5. Check konfigurasi firewall yang diterapkan di proxy
  6. Jalankan servicenya
  7. Test konfigurasi di proxy dan client
File konfigurasi squid: /etc/squid/squid.conf (versi saya)
#SQUID 2.6.STABLE12
#Author by: http://fxekobudi.net
 
# OPTION JARINGAN
# -----------------------------------------------------------------------------
http_port 3128
icp_port 0
 
# OPTION UKURAN CACHE
# -------------------------------------------------------------------
cache_mem 256 MB
cache_swap_low 94
cache_swap_high 96
maximum_object_size 16384 KB
minimum_object_size 4 KB
maximum_object_size_in_memory 2048 KB
fqdncache_size 1024
cache_replacement_policy heap GDSF
memory_replacement_policy heap GDSF
 
# DIREKTORI LOG DAN CACHE
# ------------------------------------------------------------------
cache_dir aufs /var/spool/squid 9000 16 256
access_log /var/log/squid/access.log squid
cache_log /var/log/squid/cache.log
cache_store_log none
 
# TUNING CACHE PROXY
# ------------------------------------------------------------------
refresh_pattern ^ftp:        1440    20%    10080
refresh_pattern ^gopher:    1440    0%    1440
refresh_pattern .        0    20%    4320
negative_ttl 1 minutes
 
# TIMEOUT
# -----------------------------------------------------------------
half_closed_clients off
# -------------------------------------
# Memblok situs terlarang (blacklist)secara manual
# -------------------------------------
acl noblacklist dstdomain "/etc/squid/blacklist/no-blacklist.txt"
acl katablacklist url_regex -i "/etc/squid/blacklist/kata-blacklist.txt"
acl domainblacklist dstdomain "/etc/squid/blacklist/domain-blacklist.txt"
acl ipblacklist dst "/etc/squid/blacklist/ip-blacklist.txt"
acl tdkbebasdownload time 08:00-13:00
 
# AKSES KONTROL
# ------------------------------------------------------------------
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
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 CONNECT method CONNECT
# -------------------------------------
# Daftar IP address
# -------------------------------------
acl lab1 src 192.168.254.1-192.168.254.40/255.255.255.255
acl staf-it src 192.168.254.41-192.168.254.42/255.255.255.255
acl lab2 src 192.168.254.43-192.168.254.44/255.255.255.255
acl ruang1 src 192.168.1.1-192.168.1.8/255.255.255.255
acl ruang2 src 192.168.1.11-192.168.1.17/255.255.255.255
 
# -------------------------------------
# Memblok situs terlarang secara manual
# -------------------------------------
http_access allow noblacklist
http_access deny katablacklist
http_access deny domainblacklist
http_access deny ipblacklist
http_access allow manager localhost
http_access deny manager
# -------------------------------------
# Rule yang saya terapkan
# -------------------------------------
http_access allow lab1
http_access allow staf-it
http_access allow lab2
http_access allow ruang1
http_access allow ruang2
acl magic_words2 url_regex -i ftp .exe .mp3 .vqf .tar.gz .gz .tar.bz2 .bz2 .rpm .zip .rar .avi .mpeg .mpe .mpg .qt .ram .rm .raw .wav .iso
 
# Cancel download if file is bigger than 2 MB = 2000x1024 byte = 2048000 byte
reply_body_max_size 2048000 allow magic_words2 tdkbebasdownload
 
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
http_reply_access allow all
icp_access allow all
 
# PARAMETER ADMINISTRATOR
# -----------------------------------------------------------------
cache_mgr fxekobudi@gmail.com
cache_effective_user squid
cache_effective_group squid
visible_hostname proxy.fxekobudi.local
 
# PESAN ERROR DALAM BAHASA INDONESIA
# --------------------------------------------------------------------
error_directory /usr/share/squid/errors/Indonesian
Agar fungsi blacklist manual itu dapat digunakan, buat direktori berisi file-file disebutkan dalam blacklist manual:
# mkdir /etc/squid/blacklist
# cd /etc/squid/blacklist/
# vim no-blacklist.txt
# vim kata-blacklist.txt
# vim domain-blacklist.txt
# vim ip-blacklist.txt
 
Minimal dimasukkan satu item untuk masing-masing file tersebut, karena jika tidak, maka saat kita melihat error log squid sesaat setelah service dijalankan, akan ada pesan error tidak menemukan item pada file tersebut...Selain itu, saya juga menyertakan konfigurasi untuk pesan Error dari Proxy squid dalam bentuk bahasa indonesia, agar user di tempat kerja saya lebih mudah memahami maksudnya... Ide pesan error ini kemudian menjadi inspirasi saya saat mengkonfigurasi redirect SquidGuard untuk mengarah kepada file yang sengaja saya buat di root direktori web server proxy. Untuk melakukannya, tinggal copykan saja pesan Error dalam bahasa Inggris ke direktori lokasi pesan error berbahasa Indonesia.
# cp /usr/share/squid/errors/English /usr/share/squid/errors/Indonesian
trus terjemahkan file-filenya... Untuk menjalankan servicenya, gunakan saja perintah:
# /sbin/service squid start
Oh ya, Anda juga perlu menambahkan di konfigurasi Firewall menggunakan Iptable agar client diperbolehkan mengakses Internet ini melalui proxy, request client ke proxy dengan IP address yang terdaftar diperbolehkan melalui port 3128 (atau 8080) tergantung konfigurasi yang Anda gunakan... Saya jadi ingat waktu pertama kali mencoba, koneksi internet di server pake proxy udah jalan, tapi kok clientnya ngga bisa akses, eh ternyata emang client belum diperbolehkan akses ke IP address dan portnya proxy... Hehe. Agar bisa akses ke proxy, rule iptable-nya untuk file /etc/sysconfig/iptables harus memuat rule ini: (saya pakai konfigurasi firewall bawaan Fedora Core)
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3128 -j ACCEPT
Untuk menerapkan IP forwarding, saya edit file /etc/sysctl.conf dan memberi nilai 1 (enable) untuk direktive:
net.ipv4.ip_forward = 0 menjadi net.ipv4.ip_forward = 1
Konfigurasi proxy ini saya gunakan sebagian ditempat kerja saya (YBHK dan persekolahan Tarsisius 1, Damai, Tarsisius 2, Vianney, dan Tarsisius Vireta) dengan beberapa tambahan fitur yang tidak dapat saya sebutkan disini... Dengan alasan keamanan. Hehe...Sedangkan konfigurasi squid untuk menggunakan blacklist dari redirect SquidGuard dan firewall-nya akan saya tulis beberapa minggu ke depan... Setelah saya pulang berlibur ke rumah orang tua saya sekaligus tanah kelahiran saya di Sarolangun, Jambi.
Tagged with:  

121 Responses to Proxy Server Linux dengan Squid

  1. sheva_Cullen says:
    Firefox 3.6.13 Firefox 3.6.13 Windows XP Windows XP

    Baru Belajar ni Mas…..
    server proxynya pake ubuntu,trus ada 2 client yang ga bisa browsing,yang lainnya bisa trus iP nya juga sudah di seting…..
    memang sich yang 2 ini masih pake windows 2000, yang lainnya pake windowsXP apakah berpengaruh mas???????
    harus bagaimana ni?????
    mohon infonya mas…..
    terimakasih….

  2. deviia says:
    Firefox 3.0 Firefox 3.0 GNU/Linux GNU/Linux

    mas,saya baru mempelajari squid.
    apa saja yang harus di konfig dalam honfigurasi squid??
    dan apa fungsi dari konfigurasi tersebut??

  3. rahmad kurniadi says:
    Firefox 3.5.5 Firefox 3.5.5 Windows XP Windows XP

    menarik sekali mas eko…

    oya kl tampilan error seperti di bawah ini, pakai linux apa mas? mf soalnya kurang ngerti soal ini…. terus di warnet ku pakai mikrotik rooterOS juga yg diinstal di PC jadi sy menggunakan 2 PC; 1. mikrotik 2. Proxy dan 3 LANCARD sementara aku gak tau soalnya yg set kemaren org lain (teknisi), mohon pencerahan mksh….

    The requested URL could not be retrieved

    While trying to retrieve the URL: http://123/

    The following error was encountered:

    Unable to determine IP address from host name for 123

    The dnsserver returned:

    Name Error: The domain name does not exist.

    This means that:

    The cache was not able to resolve the hostname presented in the URL.
    Check if the address is correct.

    Your cache administrator is webmaster.
    Generated Mon, 09 May 2011 20:24:07 GMT by proxylatansa (squid/2.7.STABLE3)

  4. MitraTech says:
    Firefox 5.0 Firefox 5.0 Windows XP Windows XP

    Salam kenal mas,
    Apakah bisa dibantu untuk pembuatan squid ubuntu direct dari Mikrotik dgn spesifikasi pc hdd 500GB | Mem 4GB dgn topologi jaringan Inet — modem — pcrouter — proxy server ubuntu 10.10 — switch hub — client

    Saya sangat apresiasi dengan tampilan bahasa nasional nya mas. tolong mas !

  5. harits says:
    Google Chrome 14.0.797.0 Google Chrome 14.0.797.0 Windows 7 Windows 7

    mas kalo buat liat log squid yang gui itu apa ya?
    thx ya mas

  6. Google Chrome 14.0.835.202 Google Chrome 14.0.835.202 Windows 7 Windows 7

    terimakasih atas ilmunya :)

  7. mona says:
    Firefox 3.0.19 Firefox 3.0.19 Windows XP Windows XP

    agan,, boleh kish saran gak??
    cara pembuatan memnbangn proxy server berbasis LInux ubuntu 10 di gmana??
    makasi sebelumnya, :-)

  8. Ipang says:
    Firefox 6.0.2 Firefox 6.0.2 Windows 7 Windows 7

    coba untuk memperaktekan..
    izin yah untuk di coba ??

    hehehehehe

  9. antechno says:
    Google Chrome 15.0.874.106 Google Chrome 15.0.874.106 Windows 7 Windows 7

    Blogwalking

  10. karfi says:
    Google Chrome 15.0.874.106 Google Chrome 15.0.874.106 Windows 7 Windows 7

    terima kasih ilmunya pak,

  11. arif says:
    Google Chrome 14.0.825.0 Google Chrome 14.0.825.0 Windows XP Windows XP

    salam kenal mas ,,,
    ku mau tanya ,,, cara mengalihkan proxy ke blog’s gimana ya mas.

    tros cara mengaur waktu ,, saat kita blok suatu situs ,, misal kita mau blok facebook di jam sekolah ,,, tros nanti jam 16.00 , secara otomatis tidak terblok lg ,,, itu giimana ya mas ,,, trimakasih sebelumnya mas

  12. ardianta says:
    Firefox 6.0.2 Firefox 6.0.2 Windows XP Windows XP

    bagaimana caranyamenggunakan SQUID tanpa PC tambahan?

  13. Dede says:
    Google Chrome 16.0.912.75 Google Chrome 16.0.912.75 Windows XP Windows XP

    Salam kenal mas Eko,

    apakah ada caranya untuk menggunakan squid user (ex. ncsa) yang dihubungkan dengan LDAP (User di Active Directory)? mohon pencerahannya.

    terima kasih.

  14. ilham says:
    Firefox 5.0 Firefox 5.0 Windows XP Windows XP

    mas eko..
    gmna klo kita ingin memulai belajar judul ini?
    apa saja yg di perlukan…thx

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">