Setting Squid Proxy di Ubuntu

Secara sederhana untuk setting squid proxy di ubuntu sebagai berikut:

Asumsi
LAN:  eth1 dengan ip : 192.168.1.0/24
WAN: eth0 dengan ip: dari ISP

  1. Login sebagai root/sudoers
    root@proxy:#
    atau jika user sudah diset sbg sudoers
    adnan@proxy:$ sudo -s
    password: [passwd user adnan]
  2. Install squid
    #apt-get install squid
  3. Buat direktori cache1 dan cache2 untuk menyimpan cache squid
    langkah ini bisa ditiadakan jika anda menggunakan folder default dari squid
    /var/spool/squid
  4. Buat owner folder cache1 dan cache2 untuk proxy
    #chown -R proxy:proxy /cache1
    #chown -R proxy:proxy /cache2
  5. Setting konfigurasi squid
    #vim /etc/squid/squid.conf

    Contoh konfigurasi squid transparent proxy sederhana / squid configuration

    http_port 3128 transparent
    hierarchy_stoplist cgi-bin ?
    acl QUERY urlpath_regex cgi-bin \?

    cache deny QUERY
    cache_mem 6 MB
    cache_dir ufs /cache1 100 16 256
    cache_dir ufs /cache2 100 16 256
    access_log /var/log/squid/access.log squid
    cache_log /var/log/squid/cache.log
    cache_store_log /var/log/squid/store.log
    dns_nameservers 202.134.0.155 202.134.2.5 203.130.196.5
    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
    acl pengguna src 192.168.1.0/255.255.255.0
    http_access allow purge localhost
    http_access deny purge
    http_access deny !Safe_ports
    http_access deny CONNECT !SSL_ports
    http_access deny blacklist
    http_access allow localhost
    http_access allow pengguna
    http_access deny all
    icp_access allow all
    visible_hostname localhost
    delay_pools 1
    delay_class 1 3
    delay_access 1 allow pengguna
    delay_access 1 deny all
    delay_parameters 1 32000/32000 -1/-1 20000/32000
    always_direct allow all

  6. Mentranslasikan LAN dan mengarahkan LAN ke squid
    Langsung kita buat saja di rc.d agar ketika server kita jalankan dia langsung menjalankan setting yang kita pasang.

    #vim /etc/init.d/gateway

    isikan script berikut:
    #! /bin/sh
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -A POSTROUTING -j MASQUERADE -t nat -s 192.168.1.0/24 -o eth0
    iptables -t nat -p tcp -A PREROUTING -s 192.168.1.0/24 -d 0/0 - -dport 80 -j REDIRECT - -to-port 3128

  7. Buat file gateway itu agar bisa dieksekusi
    #chmod +x /etc/init.d/gateway
  8. Update rc.d agar file gateway dieksekusi pada saat booting
    #update-rc.d gateway defaults
  9. Restart / jalankan squid
    #squid -z
    #/etc/init.d/squid restart
    #/etc/init.d/gateway
  10. Jika diinginkan proxy tidak transparent, maka hilangkan kata transparent pada setting-an squid
    #vim /etc/squid/squid.conf
    ———————————–
    http_port 3128 transparent
    hierarchy_stoplist cgi-bin ?
    ————————————

    menjadi
    ————————————
    http_port 3128
    hierarchy_stoplist cgi-bin ?
    ————————————

Categories: Serba-serbi
Koko
bro, step-step udah saya ikut tapi squid tidak bisa cache.
mohn pencerahannya
TQU
10 April 10 at 05:46
Mas mau tanya.
Untuk mem blok beberapa situs atau alamat website settingannya di squid di bagian mana ya mas.
nuwun sebelumnya
20 May 10 at 11:25
nico
ini topologinya gimana?
28 May 10 at 16:36
walah kirain halaman pesbuk…

btw makasih mas…
salam persahabatan
27 July 10 at 20:05