Konfigurasi Squid Proxy Server Di CentOS 6.6
Spesifikasi Server HP Proliant DL320
Prosessor : Intel Xeon E3-1220v2
RAM : 4GB DDR3-1600 UDIMM
VGA : Matrox G200
HDD : 2TB Sata
NIC : 2 x GbE NIC
OS : Centos 6.6 x86_64
1. Konfigurasi Jaringan
eth0 : (ke Internet)
IP = 192.168.188.254/26
Gateway = 192.168.188.193
DNS = 202.137.3.110, 202.137.3.111
eth1 : (ke LAN)
IP = 192.168.88.1/29
Topologi Jaringan
Setelah proses instal selesai masuk sebagai root
lihat apakah ethernet sudah aktif atau belum dengan perintah :
jika belum aktif, aktifkan dengan perintah :
cek kembali dengan ifconfig
kemudian setting ip address di eth0
Kemudian isikan dengan script sebagai berikut :
Tekan CTRL+O untuk menyimpan, dan keluar dengan CTRL+X
kemudian setting ip address di eth1
Kemudian isikan dengan script sebagai berikut :
Tekan CTRL+O untuk menyimpan, dan keluar dengan CTRL+X
Keterangan :
DEVICE=Nama ethernet yang terdeteksi, pada kasus ini yaitu eth0 dapat berubah menjadi eth1, eth2 dan sebagainya.
BOOTPROTO=Jenis Networknya, pada kasus ini dituliskan static karena kita memberikan ip address secara manual. Bila jenis networknya automatis/dhcp kita tuliskan dhcp.
ONBOOT=Adalah perintah apakah ethernet diaktifkan ketika start up atau dapat dikatakan auto start. Pada kasus ini kita berikan perintah yes. Bila kita berikan perintah no maka pada saat sistem operasi melakukan start up ethernet tidak akan aktif secara automatis.Cek kembali dengan menggunakan ifconfig dan lihat apakah ip sudah muncul, bila sudah muncul lakukan test ping ke DNS servernya, jika ip belum muncul tuliskan perintah ifup eth0 dan restart kembali service networknya.
2. Konfigurasi Firewall Dengan Iptables
buat file squidfw.sh dengan perintah
tambahkan konfigurasi firewall berikut (sesuaikan dengan konfigurasi ethernet yang digunakan)
jalankan dengan perintah
tambahkan perintah “sh /root/squidfw.sh” ke /etc/rc.local
3. Konfigurasi Proxy Squid 3.1
Update Centos 6.6
Install aplikasi Development Tools
Install squid
Selanjutnya Edit seting squid.conf pada squid yang telah diinstall
Konfigurasi squid
Membuat folder-folder swap/cache di dalam folder cache yang telah ditentukan dengan perintah:
Cek konfig squid, apakah ada yang error atau tidak
Apabila tidak ada error jalankan squid sebagai daemon
Prosessor : Intel Xeon E3-1220v2
RAM : 4GB DDR3-1600 UDIMM
VGA : Matrox G200
HDD : 2TB Sata
NIC : 2 x GbE NIC
OS : Centos 6.6 x86_64
1. Konfigurasi Jaringan
eth0 : (ke Internet)
IP = 192.168.188.254/26
Gateway = 192.168.188.193
DNS = 202.137.3.110, 202.137.3.111
eth1 : (ke LAN)
IP = 192.168.88.1/29
Topologi Jaringan
Setelah proses instal selesai masuk sebagai root
lihat apakah ethernet sudah aktif atau belum dengan perintah :
- ifconfig
- ifconfig eth0 up
- ifconfig eth1 up
kemudian setting ip address di eth0
- nano /etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE=eth0
- TYPE=Ethernet
- UUID=757e8f68-8179-471e-8423-a226f991f962
- ONBOOT=yes
- NM_CONTROLLED=yes
- BOOTPROTO=static
- HWADDR=A4:5D:36:C5:97:1C
- IPADDR=192.168.188.254
- PREFIX=26
- GATEWAY=192.168.188.193
- DNS1=202.137.3.110
- DNS2=202.137.3.111
- DEFROUTE=yes
- IPV4_FAILURE_FATAL=yes
- IPV6INIT=no
- NAME="INTERNET-eth0"
kemudian setting ip address di eth1
- nano /etc/sysconfig/network-scripts/ifcfg-eth1
- DEVICE=eth1
- HWADDR=A4:5D:36:C5:97:1D
- TYPE=Ethernet
- UUID=6c614425-1e8e-4ce5-a2c3-d99926c1adbf
- ONBOOT=yes
- NM_CONTROLLED=yes
- BOOTPROTO=static
- IPADDR=192.168.88.1
- PREFIX=29
- DEFROUTE=yes
- IPV4_FAILURE_FATAL=yes
- IPV6INIT=no
- NAME="LAN-eth1"
Keterangan :
DEVICE=Nama ethernet yang terdeteksi, pada kasus ini yaitu eth0 dapat berubah menjadi eth1, eth2 dan sebagainya.
BOOTPROTO=Jenis Networknya, pada kasus ini dituliskan static karena kita memberikan ip address secara manual. Bila jenis networknya automatis/dhcp kita tuliskan dhcp.
ONBOOT=Adalah perintah apakah ethernet diaktifkan ketika start up atau dapat dikatakan auto start. Pada kasus ini kita berikan perintah yes. Bila kita berikan perintah no maka pada saat sistem operasi melakukan start up ethernet tidak akan aktif secara automatis.Cek kembali dengan menggunakan ifconfig dan lihat apakah ip sudah muncul, bila sudah muncul lakukan test ping ke DNS servernya, jika ip belum muncul tuliskan perintah ifup eth0 dan restart kembali service networknya.
2. Konfigurasi Firewall Dengan Iptables
buat file squidfw.sh dengan perintah
- nano /root/squidfw.sh
- #!/bin/sh
- # squid server IP
- SQUID_SERVER="192.168.88.1"
- # Interface connected to Internet
- INTERNET="eth0"
- # Interface connected to LAN
- LAN_IN="eth1"
- # Squid port
- SQUID_PORT="3128"
- # DO NOT MODIFY BELOW
- # Clean old firewall
- iptables -F
- iptables -X
- iptables -t nat -F
- iptables -t nat -X
- iptables -t mangle -F
- iptables -t mangle -X
- # Load IPTABLES modules for NAT and IP conntrack support
- modprobe ip_conntrack
- modprobe ip_conntrack_ftp
- # For win xp ftp client
- #modprobe ip_nat_ftp
- echo 1 > /proc/sys/net/ipv4/ip_forward
- # Setting default filter policy
- iptables -P INPUT DROP
- iptables -P OUTPUT ACCEPT
- # Unlimited access to loop back
- iptables -A INPUT -i lo -j ACCEPT
- iptables -A OUTPUT -o lo -j ACCEPT
- # Allow UDP, DNS and Passive FTP
- iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
- # set this system as a router for Rest of LAN
- iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
- iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
- # unlimited access to LAN
- iptables -A INPUT -i $LAN_IN -j ACCEPT
- iptables -A OUTPUT -o $LAN_IN -j ACCEPT
- # REDIRECT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy
- iptables -t nat -A PREROUTING -i $LAN_IN -p tcp -m tcp --dport 80 -j REDIRECT --to-ports $SQUID_PORT
- # if it is same system
- iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
- # Allow SSH
- iptables -A INPUT -i $INTERNET -p tcp -m tcp --dport 22 -j ACCEPT
- # DROP everything and Log it
- iptables -A INPUT -j LOG
- iptables -A INPUT -j DROP
- sh /root/squidfw.sh
- nano /etc/rc.local
3. Konfigurasi Proxy Squid 3.1
Update Centos 6.6
- yum update
- yum groupinstall 'Development Tools'
- yum -y install squid
- nano /etc/squid/squid.conf
- #
- # Recommended minimum configuration:
- #
- acl manager proto cache_object
- acl localhost src 127.0.0.1/32
- acl to_localhost dst 127.0.0.0/8
- #acl localhost src 127.0.0.1/32 ::1
- #acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
- # Example rule allowing access from your local networks.
- # Adapt to list your (internal) IP networks from where browsing
- # should be allowed
- #acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
- #acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
- #acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
- #acl localnet src fc00::/7 # RFC 4193 local private network range
- #acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
- 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
- acl all src all
- acl client src 192.168.88.0/24
- http_access allow client
- http_access allow manager localhost
- http_access deny manager
- http_access deny !Safe_ports
- http_access deny CONNECT !SSL_ports
- # We strongly recommend the following be uncommented to protect innocent
- # web applications running on the proxy server who think the only
- # one who can access services on "localhost" is a local user
- #http_access deny to_localhost
- #
- # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
- #
- # Example rule allowing access from your local networks.
- # Adapt localnet in the ACL section to list your (internal) IP networks
- # from where browsing should be allowed
- #http_access allow localnet
- http_access allow localhost
- # And finally deny all other access to this proxy
- http_access deny all
- # NETWORK OPTION
- http_port 3128 intercept
- hierarchy_stoplist cgi-bin ?
- visible_hostname proxy.pipit-pmj.co.id
- # MEMORY CACHE OPTION
- cache_mem 6 MB
- maximum_object_size_in_memory 4 KB
- memory_replacement_policy heap GDSF
- # DISK CACHE OPTIONS
- minimum_object_size 0 KB
- maximum_object_size 512 MB
- cache_swap_low 97
- cache_swap_high 99
- cache_replacement_policy heap LFUDA
- cache_dir aufs /cache1/cache 40000 94 256
- cache_dir aufs /cache2/cache 40000 94 256
- cache_dir aufs /cache3/cache 40000 94 256
- cache_dir aufs /cache4/cache 40000 94 256
- # LOGFILE OPTIONS
- access_log /var/log/squid/access.log squid
- cache_log /var/log/squid/cache.log
- cache_store_log none
- cache_swap_log /var/spool/squid/swap.state
- logfile_rotate 5
- log_fqdn off
- log_icp_queries off
- buffered_logs off
- emulate_httpd_log off
- # OPTIONS FOR TUNING THE CACHE
- refresh_pattern -i \.swf$ 20160 80% 20160 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private ignore-auth
- refresh_pattern -i \.gif$ 20160 80% 20160 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private ignore-auth
- refresh_pattern -i \.jpg$ 20160 80% 20160 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private ignore-auth
- refresh_pattern -i \.jpeg$ 20160 80% 20160 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private ignore-auth
- refresh_pattern -i \.exe$ 20160 80% 20160 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private ignore-auth
- # 1 year = 525600 mins, 1 month = 20160 mins, 1 day = 1440
- refresh_pattern ^.*(utm\.gif|ads\?|rmxads\.com|ad\.z5x\.net|bh\.contextweb\.com|bstats\.adbrite\.com|a1\.interclick\.com|ad\.trafficmp\.com|ads\.cubics\.com|ad\.xtendmedia\.com|\.googlesyndication\.com|advertising\.com|yieldmanager|game-advertising\.com|pixel\.quantserve\.com|adperium\.com|doubleclick\.net|adserving\.cpxinteractive\.com|syndication\.com|media.fastclick.net).* 20160 20% 20160 ignore-no-cache ignore-private override-expire ignore-reload ignore-auth
- refresh_pattern ^.*safebrowsing.*google 20160 80% 20160 override-expire ignore-reload ignore-no-cache ignore-private ignore-auth
- refresh_pattern ^http://((cbk|mt|khm|mlt)[0-9]?)\.google\.co(m|\.uk) 20160 80% 20160 override-expire ignore-reload ignore-private
- refresh_pattern ytimg\.com.*\.jpg 20160 80% 20160 override-expire ignore-reload
- refresh_pattern images\.friendster\.com.*\.(png|gif) 20160 80% 20160 override-expire ignore-reload
- refresh_pattern garena\.com 20160 80% 20160 override-expire reload-into-ims
- refresh_pattern photobucket.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png) 20160 80% 20160 override-expire ignore-reload
- refresh_pattern vid\.akm\.dailymotion\.com.*\.on2\? 20160 80% 20160 ignore-no-cache override-expire override-lastmod
- refresh_pattern mediafire.com\/images.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png) 20160 80% 20160 reload-into-ims override-expire ignore-private
- refresh_pattern ^http:\/\/images|pics|thumbs[0-9]\. 20160 80% 20160 reload-into-ims ignore-no-cache ignore-reload override-expire
- refresh_pattern ^http:\/\/www.onemanga.com.*\/ 20160 80% 20160 reload-into-ims ignore-no-cache ignore-reload override-expire
- refresh_pattern ^http://v\.okezone\.com/get_video\/([a-zA-Z0-9]) 20160 80% 20160 override-expire ignore-reload ignore-no-cache ignore-private ignore-auth override-lastmod
- #images facebook
- refresh_pattern -i \.facebook.com.*\.(jpg|png|gif) 20160 80% 20160 ignore-reload override-expire ignore-no-cache
- refresh_pattern -i \.fbcdn.net.*\.(jpg|gif|png|swf|mp3) 20160 80% 20160 ignore-reload override-expire ignore-no-cache
- refresh_pattern static\.ak\.fbcdn\.net*\.(jpg|gif|png) 20160 80% 20160 ignore-reload override-expire ignore-no-cache
- refresh_pattern ^http:\/\/profile\.ak\.fbcdn.net*\.(jpg|gif|png) 20160 80% 20160 ignore-reload override-expire ignore-no-cache
- #All File
- refresh_pattern -i \.(3gp|7z|ace|asx|bin|deb|divx|dvr-ms|ram|rpm|exe|inc|cab|qt) 20160 80% 20160 ignore-no-cache override-expire override-lastmod reload-into-ims
- refresh_pattern -i \.(rar|jar|gz|tgz|bz2|iso|m1v|m2(v|p)|mo(d|v)|arj|lha|lzh|zip|tar) 20160 80% 20160 ignore-no-cache override-expire override-lastmod reload-into-ims
- refresh_pattern -i \.(jp(e?g|e|2)|gif|pn[pg]|bm?|tiff?|ico|swf|dat|ad|txt|dll) 20160 80% 20160 ignore-no-cache override-expire override-lastmod reload-into-ims
- refresh_pattern -i \.(avi|ac4|mp(e?g|a|e|1|2|3|4)|mk(a|v)|ms(i|u|p)|og(x|v|a|g)|rm|r(a|p)m|snd|vob) 20160 80% 20160 ignore-no-cache override-expire override-lastmod reload-into-ims
- refresh_pattern -i \.(pp(t?x)|s|t)|pdf|rtf|wax|wm(a|v)|wmx|wpl|cb(r|z|t)|xl(s?x)|do(c?x)|flv|x-flv) 20160 80% 20160 ignore-no-cache override-expire override-lastmod reload-into-ims
- refresh_pattern ^ftp: 1440 90% 201600 override-lastmod reload-into-ims
- refresh_pattern ^gopher: 1440 0% 1440 override-lastmod reload-into-ims
- refresh_pattern (cgi-bin|\?) 0 0% 0
- refresh_pattern . 0 80% 20160 override-lastmod reload-into-ims
- # SNMP OPTIONS
- #snmp_port 3401
- #acl snmppublic snmp_community public
- #snmp_access allow snmppublic all
- # OPTIMIZING
- memory_pools off
- client_db off
- coredump_dir /cache1/squid
- reload_into_ims on
- balance_on_multiple_ip on
- vary_ignore_expire on
- pipeline_prefetch on
- quick_abort_min 16 KB
- quick_abort_max 16 KB
- quick_abort_pct 95
- shutdown_lifetime 10 seconds
- half_closed_clients off
- cache_effective_user squid
- cache_effective_group squid
- dns_nameservers 202.137.3.110 202.137.3.111
- ipcache_size 2048
- ipcache_low 90
- ipcache_high 96
- # MARKING ZPH SQUID 3.1
Memberikan building/permission pada folder/partisi cache squid
- chown squid:squid /cache1 && chmod 755 /cache1
- chown squid:squid /cache2 && chmod 755 /cache2
- chown squid:squid /cache3 && chmod 755 /cache3
- chown squid:squid /cache4 && chmod 755 /cache4
- chown squid:squid /cache5 && chmod 755 /cache5
- /usr/sbin/squid -z
- /usr/sbin/squid -k parse
- /etc/squid/sbin/squid -NDd1 &
- service squid start
Tidak ada komentar:
Posting Komentar