0% found this document useful (0 votes)
306 views

Proxy Otomatis

This document provides instructions to install and configure Squid proxy server with Tproxy on a 64-bit Debian/Ubuntu system. It begins by checking the OS version and kernel, then loads required kernel modules. Various system parameters are tuned, Squid is compiled from source and configured. The squid.conf file sets access controls and defines ports for intercepting and transparent proxying of traffic. Mobile apps and sites are exempted from caching to avoid issues.

Uploaded by

Ahmad Jumadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
306 views

Proxy Otomatis

This document provides instructions to install and configure Squid proxy server with Tproxy on a 64-bit Debian/Ubuntu system. It begins by checking the OS version and kernel, then loads required kernel modules. Various system parameters are tuned, Squid is compiled from source and configured. The squid.conf file sets access controls and defines ports for intercepting and transparent proxying of traffic. Mobile apps and sites are exempted from caching to avoid issues.

Uploaded by

Ahmad Jumadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 70

#!

/bin/bash
clear
echo

"|
=============================================================
========|"
echo | Instalasi Squid Tproxy Otomatis Faisal Reza http://www.imxpert.co |
echo | Debian 8/Ubuntu 14.04 |
echo | 64 bit |
echo | September 2015 |
echo
+===========================================================
==========+
echo
# Versi Squid yang akan diinstall
SQVER=3.5.7

# Cek Versi OS, harus 64 bit


Z=`cat /etc/debian_version`

V=`uname -r`
ER=ERROR, linux-nya bukan 64 bit
ER2=ganti versi instalasi linux nya
P=`uname -m`
if [ $P = x86_64 ] ; then
echo Versi Linux : $Z
echo Versi Kernel : $V
echo Versi Squid : $SQVER
else
echo $ER
echo
echo $ER2
echo
exit 0
f
echo

# Tuning Parameter Kernel

echo 4 >> /proc/sys/net/ipv4/tcp_fn_timeout


mv /etc/sysctl.conf /etc/sysctl.conf_
touch /etc/sysctl.conf

echo kernel.panic = 30
kernel.panic_on_oops = 30
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
fs.fle-max = 65536
vm.swappiness = 5
vm.vfs_cache_pressure=50
vm.mmap_min_addr = 4096
vm.overcommit_ratio = 0
vm.overcommit_memory = 0
kernel.shmmax = 268435456
kernel.shmall = 268435456

vm.min_free_kbytes = 65536
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.rp_flter = 0
net.ipv4.conf.default.rp_flter = 0
net.ipv4.conf.eth0.rp_flter = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.default.log_martians = 0
net.ipv4.tcp_fn_timeout = 15

net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.conf.all.bootp_relay = 0
net.ipv4.conf.all.proxy_arp = 0
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_rfc1337 = 1
net.ipv4.tcp_congestion_control = cubic
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_mem = 65536 131072 262144
net.ipv4.udp_mem = 65536 131072 262144

net.ipv4.tcp_rmem = 8192 87380 16777216


net.ipv4.udp_rmem_min = 16384
net.core.rmem_default = 87380
net.core.rmem_max = 16777216
net.ipv4.tcp_wmem = 8192 65536 16777216
net.ipv4.udp_wmem_min = 16384
net.core.wmem_default = 65536
net.core.wmem_max = 16777216
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 4096
net.core.dev_weight = 64
net.core.optmem_max = 65536
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 16384
net.ipv4.tcp_orphan_retries = 0
net.ipv4.ipfrag_high_thresh = 512000

net.ipv4.ipfrag_low_thresh = 446464
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_moderate_rcvbuf = 1
net.unix.max_dgram_qlen = 50
net.ipv4.neigh.default.gc_thresh3 = 2048
net.ipv4.neigh.default.gc_thresh2 = 1024
net.ipv4.neigh.default.gc_thresh1 = 32
net.ipv4.neigh.default.gc_interval = 30
net.ipv4.neigh.default.proxy_qlen = 96
net.ipv4.neigh.default.unres_qlen = 6
net.ipv4.tcp_ecn = 1
net.ipv4.tcp_reordering = 3
net.ipv4.tcp_retries2 = 15
net.ipv4.tcp_retries1 = 3 > /etc/sysctl.conf

# Tuning File Limit


echo 65536 > /proc/sys/fs/fle-max
echo * soft nofle 65536

* hard nofle 65536


root soft nofle 65536
root hard nofle 65536
proxy soft nofle 65536
proxy hard nofle 65536 > /etc/security/limits.conf
echo session required pam_limits.so >> /etc/pam.d/common-session

# Load Kernel modules yang diperlukan untuk Tproxy


modprobe ip_tables
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe xt_TPROXY
modprobe xt_socket
modprobe xt_mark
modprobe nf_nat

modprobe nf_conntrack_ipv4
modprobe nf_conntrack
modprobe nf_defrag_ipv4
modprobe ipt_REDIRECT

echo ip_conntrack
ip_tables
ip_conntrack_ftp
ip_conntrack_irc
iptable_nat
ip_nat_ftp
xt_TPROXY
xt_socket
xt_mark
nf_nat
nf_conntrack_ipv4
nf_conntrack
nf_defrag_ipv4

ipt_REDIRECT> /etc/modules

# Set Maksimum Ulimit


echo ulimit -Hn 65536
ulimit -Sn 65535>> /etc/profle

# Deteksi IP Server & Set Hostname


IPSERV=$(ifconfg eth0 | grep inet addr: | cut -d: -f2 | awk { print $1})
HOST_NAME=tproxy.imxpert.co

# Update & Upgrade Sistem

echo Menambahkan Repository untuk Monitorix


echo deb http://apt.izzysoft.de/ubuntu generic universe >> /etc/apt/source.list
cd /usr/src
wget -c http://apt.izzysoft.de/izzysoft.asc
apt-key add izzysoft.asc

echo Upgrade Paket Sistem


sleep 2
apt-get update
apt-get upgrade -y

echo Y | apt-get install build-essential fakeroot pastebinit checkinstall libcap-dev libssl-dev htop iftop
iptraf mtr-tiny ccze bwm-ng

# Instalasi & Kompilasi Squid


mkdir -p /usr/share/squid
mkdir -p /usr/share/squid/icons
mkdir -p /cache

echo Download Squid Source dari http://www.squid-cache.org;


sleep 1
cd /usr/src
wget -c http://www.squid-cache.org/Versions/v3/3.5/squid-$SQVER.tar.bz2
tar -jxf squid-$SQVER.tar.bz2

cd squid-$SQVER
make clean && make distclean
clear

echo Memulai Konfgurasi & Kompilasi Squid


sleep 2

./confgure prefx=/usr bindir=/usr/bin sbindir=/usr/sbin libexecdir=/usr/lib/squid


sysconfdir=/etc/squid localstatedir=/var libdir=/usr/lib includedir=/usr/include
datadir=/usr/share/squid infodir=/usr/share/info mandir=/usr/share/man disable-dependencytracking disable-strict-error-checking enable-async-io=48 with-aufs-threads=48 withpthreads with-openssl enable-storeio=aufs,diskd enable-removal-policies=lru,heap with-aio
with-dl enable-icmp enable-esi enable-icap-client disable-wccp disable-wccpv2 enablekill-parent-hack enable-cache-digests disable-select enable-http-violations enable-linuxnetflter enable-follow-x-forwarded-for disable-ident-lookups enable-x-accelerator-vary
enable-zph-qos with-default-user=proxy with-logdir=/var/log/squid withpidfle=/var/run/squid.pid with-swapdir=/var/spool/squid with-large-fles enable-ltdlconvenience with-fledescriptors=65536 enable-ssl enable-ssl-crtd disable-auth disableipv6 enable-err-languages=English enable-default-err-language=English build=x86_64
build_alias=x86_64
make && checkinstall

# Set konfgurasi squid.conf, silahkan disesuaikan

rm -rf /etc/squid/squid.conf
touch /etc/squid/squid.conf

echo
#working squid.conf for squid 3.5.7 September 2015
#moffed by reza@imxpert.co
#dari berbagai sumber

# Leave coredumps in the frst cache dir


coredump_dir /cache
cache_mgr reza@imxmpert.co
visible_hostname tproxy.imxpert.co
cache_mem 16 MB
cache_swap_low 95
cache_swap_high 98
max_fledesc 10240
maximum_object_size 720 MB
maximum_object_size_in_memory 512 Bytes

minimum_object_size 0 bytes

ipcache_size 2048
ipcache_low 95
ipcache_high 98

memory_pools of
reload_into_ims on
vary_ignore_expire on

cache_replacement_policy heap LFUDA


memory_replacement_policy heap GDSF

cache_dir aufs /cache 220000 48 256

access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log

acl all src


acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl CONNECT method CONNECT

acl getmethod method GET

#always_direct allow all


#ssl_bump server-frst all

http_access deny !Safe_ports


http_access deny CONNECT !SSL_ports
#http_access deny porn
http_access allow all
http_reply_access allow all
icp_access allow all

#cache_store_log /var/log/squid/store.log
#debug_options ALL,1 22,3

http_port 8080
#https_port 3127 intercept ssl-bump generate-host-certifcates=on
dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/myCA.pem
http_port 3128 intercept
http_port 3129 tproxy

#sslcrtd_program /usr/lib/squid/ssl_crtd -s /var/squid/ssl_db/certs/ -M 4MB


#sslcrtd_children 5

#sslproxy_cert_error allow all


#sslproxy_flags DONT_VERIFY_PEER

#acl mobilegame url_regex -i *line.me


#acl mobilegame url_regex -i *line-apps.com
#acl mobilegame url_regex -i *.ksmobile*
acl mobilegamergx url_regex -i json.*$
acl mobilegame dstdomain ksmobile.com
acl mobilegame dstdomain line.me
acl mobilegame dstdomain line-apps.com
acl mobilegame dstdomain cdn-lg.line-apps.com
acl mobilegame dstdomain litmus.line-apps.com
acl mobilegame dstdomain up.cm.ksmobile.com
acl mobilegame dstdomain dl.cm.ksmobile.com
always_direct allow mobilegame
always_direct allow mobilegamergx
cache deny mobilegame
cache deny mobilegamergx

acl google url_regex -i (googlevideo.com|youtube.com)


request_header_access User-Agent deny google
request_header_replace User-Agent Mozilla/5.0 (compatible; Googlebot/2.1;
+http://www.google.com/bot.html)

acl youtube url_regex -i youtube.*(ptracking|stream_204|player_204|gen_204).*$


acl youtube url_regex -i \.c\.(youtube|google)\.com\/(get_video|videoplayback|videoplay).*$
acl youtube url_regex -i (youtube|google).*\/videoplayback\?.*
store_id_access allow youtube

acl reverbnation url_regex -i reverbnation.*(audio_player|ec_stream_song).*$


acl reverbnation url_regex -i \.c\.(reverbnation|c2lo)\.com\/(get_audio|audioplayback|audioplay).*$
store_id_access allow reverbnation

#acl googlechrome url_regex -i ^http:\/\/.*\.c\.pack\.google\.com\/.*\/(.*\.exe)


#acl googlechrome url_regex -i ^http:\/\/.*\.c\.pack\.google\.com\/.*\/.*\/(.*\.crx)
#store_id_access allow googlechrome

acl googlechrome url_regex -i .*\.google\.com\/.*$


acl googlechrome url_regex -i .*\.c\.pack\.google\.com/.*\.(exe|crx)
acl updatechrome dstdomain cache.pack.google.com
acl updatechrome dstdomain http://www.cache.pack.google.com
store_id_access allow googlechrome

refresh_pattern -i ^http:\/\/.*\.c\.pack\.google\.com\/.*\/(.*\(crx|exe) 10080 80% 43200 ignore-no-store


ignore-must-revalidate ignore-private override-expire override-lastmod reload-into-ims store-stale
refresh_pattern -i .*\.c\.pack\.google\.com/.*\.(exe|crx) 10080 80% 43200 ignore-no-store ignoremust-revalidate ignore-private override-expire override-lastmod reload-into-ims store-stale

acl windowsupdate dstdomain windowsupdate.microsoft.com


acl windowsupdate dstdomain .update.microsoft.com
acl windowsupdate dstdomain download.windowsupdate.com
acl windowsupdate dstdomain redir.metaservices.microsoft.com
acl windowsupdate dstdomain images.metaservices.microsoft.com
acl windowsupdate dstdomain c.microsoft.com
acl windowsupdate dstdomain http://www.download.windowsupdate.com

acl windowsupdate dstdomain wustat.windows.com


acl windowsupdate dstdomain crl.microsoft.com
acl windowsupdate dstdomain sls.microsoft.com
acl windowsupdate dstdomain productactivation.one.microsoft.com
acl windowsupdate dstdomain ntservicepack.microsoft.com
acl windowsupdate dstdomain http://www.update.microsoft.com

acl DENYCACHE dstdomain http://www.gemscool.com


acl DENYCACHE dstdomain ads.gemscool.com
acl DENYCACHE dstdomain log.gemscool.com
acl DENYCACHE dstdomain cinemaindo.com
cache deny DENYCACHE

acl store_id_access_list urlpath_regex \.(3gp|mp(3|4)|flv|(m|f)4v|on2|fd|avi|mov|wm(a|v)|(mp(e?g|a|


e|1|2))|mk(a|v)|jp(e?g|e|2)|gif|png|tif?|bmp|tga|svg|ico|swf|exe|ms(i|u|p)|cab|psf|mar|bin|z(ip|[0-9]
{2})|r(ar|[0-9]{2})|7z)\?
acl store_id_access_list urlpath_regex -i \.flv$ \.mp3$ \.mov$ \.mp4$ \.swf$ \
acl store_id_access_list_domain url_regex ^https?:\/\/([a-zA-Z-]+[0-9-]+)\.[A-Za-z]*\.[A-Za-z]*

acl store_id_access_list_domain url_regex (([a-z]{1,2}[0-9]{1,3})|([0-9]{1,3}[a-z]{1,2}))\.[a-z]*[09]?\.[a-z]{3}


acl store_id_access_list_path urlpath_regex \.(jp(e?g|e|2)|gif|png|tif?|bmp|ico|flv|avc|zip|mp3|3gp|rar|
on2|mar|exe)$
acl store_id_access_list_domain_CDN url_regex streamate.doublepimp.com.*\.js\? .fbcdn.net
\.rapidshare\.com.*\/[0-9]*\/.*\/[^\/]* ^http:\/\/(www\.ziddu\.com.*\.[^\/]{3,4})\/(.*) \.doubleclick\.net.*
yield$
acl store_id_access_list_domain_CDN url_regex (cbk|mt|khm|mlt|tbn)[0-9]?.google\.co(m|\.uk|\.id)
acl store_id_access_list_domain_CDN url_regex ^https?:\/\/.*.gstatic.com.*
acl store_id_access_list_domain_CDN url_regex ^http:\/\/download[0-9]{3}.avast.com/iavs5x/
acl store_id_access_list_domain_CDN url_regex ^http:\/\/dnl-[0-9]{2}.geo.kaspersky.com
acl store_id_access_list_domain_CDN url_regex ^http:\/\/[1-4].bp.blogspot.com
acl store_id_access_list_domain url_regex ^http:\/\/([a-zA-Z-]+[0-9-]+)\.[A-Za-z]*\.[A-Za-z]*
acl store_id_access_list_domain url_regex (([a-z]{1,2}[0-9]{1,3})|([0-9]{1,3}[a-z]{1,2}))\.[a-z]*[09]?\.[a-z]{3}
acl store_id_access_list_domain url_regex -i ^http://fbcdn.net.squid.internal
acl store_id_access_list_path urlpath_regex \.fd\?.*\&start= \.(jp(e?g|e|2)|gif|png|tif?|bmp|ico|psf|flv|
avc|zip|mp3|3gp|rar|on2|mar|exe)$
acl store_id_access_list_domain_CDN url_regex \.rapidshare\.com.*\/[0-9]*\/.*\/[^\/]* ^http:\/\/
(www\.ziddu\.com.*\.[^\/]{3,4})\/(.*) \.doubleclick\.net.*

acl store_id_access_list_domain_CDN url_regex ^http:\/\/[.a-z0-9]*\.photobucket\.com.*\.[a-z]{3}$


quantserve\.com
acl store_id_access_list_domain_CDN url_regex ^http:\/\/[a-z]+[0-9]\.google\.co(m|\.id)
acl store_id_access_list_domain_CDN url_regex ^http:\/\/\.www[0-9][0-9]\.indowebster\.com\/(.*)(rar|
zip|flv|wm(a|v)|3gp|psf|mp(4|3)|exe|msi|avi|(mp(e?g|a|e|1|2|3|4))|cab|exe)

# Videos Confg / jz
#acl store_id_access_videocache_url url_regex -i \.googlevideo\.com\/videoplayback
\.googlevideo\.com\/videoplay \.googlevideo\.com\/get_video\?
#acl store_id_access_videocache_url url_regex -i \.google\.com\/videoplayback
\.google\.com\/videoplay \.google\.com\/get_video\?
acl store_id_access_videocache_url url_regex -i \.google\.[a-z][a-z]\/videoplayback \.google\.[a-z][az]\/videoplay \.google\.[a-z][a-z]\/get_video\?
acl store_id_access_videocache_url url_regex -i proxy[a-z0-9\-][a-z0-9][a-z0-9][a-z09]?\.dailymotion\.com\/
acl store_id_access_videocache_url url_regex -i \.vimeo\.com\/(.*)\.(flv|mp4)
acl store_id_access_videocache_url url_regex -i va\.wrzuta\.pl\/wa[0-9][0-9][0-9][0-9]?
acl store_id_access_videocache_url url_regex -i \.youporn\.com\/(.*)\.flv
acl store_id_access_videocache_url url_regex -i \.msn\.com\.edgesuite\.net\/(.*)\.flv
acl store_id_access_videocache_url url_regex -i \.tube8\.com\/(.*)\.(flv|3gp)

acl store_id_access_videocache_url url_regex -i \.mais\.uol\.com\.br\/(.*)\.flv


acl store_id_access_videocache_url url_regex -i \.blip\.tv\/(.*)\.(flv|avi|mov|mp3|m4v|mp4|wmv|rm|
ram|m4v)
acl store_id_access_videocache_url url_regex -i \.apniisp\.com\/(.*)\.(flv|avi|mov|mp3|m4v|mp4|wmv|
rm|ram|m4v)
acl store_id_access_videocache_url url_regex -i \.break\.com\/(.*)\.(flv|mp4)
acl store_id_access_videocache_url url_regex ^http:\/\/(videos.flv2.redtubefles.com)\/(.*)\/(.*)\/(.*)\/
(.*)
acl store_id_access_videocache_url url_regex -i vid\.akm\.dailymotion\.com\/
acl store_id_access_videocache_url url_regex -i [a-z0-9][0-9a-z][0-9a-z]?[0-9a-z]?[0-9az]?\.xtube\.com\/(.*)flv
acl store_id_access_videocache_url url_regex -i bitcast\.vimeo\.com\/vimeo\/videos\/
acl store_id_access_videocache_url url_regex -i va\.wrzuta\.pl\/wa[0-9][0-9][0-9][0-9]?
acl store_id_access_videocache_url url_regex -i \.fles\.youporn\.com\/(.*)\/flv\/
acl store_id_access_videocache_url url_regex -i \.msn\.com\.edgesuite\.net\/(.*)\.flv
acl store_id_access_videocache_url url_regex -i media[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/
mobile[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/ www\.tube8\.com\/(.*)\/
acl store_id_access_videocache_url url_regex -i \.mais\.uol\.com\.br\/(.*)\.flv
acl store_id_access_videocache_url url_regex -i \.video[a-z0-9]?[a-z0-9]?\.blip\.tv\/(.*)\.(flv|avi|mov|
mp3|m4v|mp4|wmv|rm|ram)

acl store_id_access_videocache_url url_regex -i video\.break\.com\/(.*)\.(flv|mp4)


acl store_id_access_videocache_url url_regex -i \.xvideos\.com\/videos\/flv\/(.*)\/(.*)\.(flv|mp4)
acl store_id_access_videocache_url url_regex -i stream\.aol\.com\/(.*)/[a-zA-Z0-9]+\/(.*)\.(flv|mp4)
acl store_id_access_videocache_url url_regex -i videos\.5min\.com\/(.*)/[0-9_]+\.(mp4|flv)
acl store_id_access_videocache_url url_regex -i msn\.com\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|
mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i msn\.(.*)\.(com|net)\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|
rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i msnbc\.(.*)\.(com|net)\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|
rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.blip\.tv\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|
mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.blip\.tv\/(.*)flename
acl store_id_access_videocache_url url_regex -i \.break\.com\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|
m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i cdn\.turner\.com\/(.*)/(.*)\.(flv)
acl store_id_access_videocache_url url_regex -i \.dailymotion\.com\/video\/[a-z0-9]{5,9}_?(.*)
acl store_id_access_videocache_url url_regex -i proxy[a-z0-9\-]?[a-z0-9]?[a-z0-9]?[a-z09]?\.dailymotion\.com\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i vid\.akm\.dailymotion\.com\/(.*)\.(flv|on2|mp4|avi|
mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)

acl store_id_access_videocache_url url_regex -i vid\.ec\.dmcdn\.net\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|


rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i video\.(.*)\.fbcdn\.net\/(.*)/[0-9_]+\.(mp4|flv|avi|mkv|
m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.mccont\.com\/ItemFiles\/(.*)?\.(flv|mp4|avi|mkv|mp3|
rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i (.*)\.myspacecdn\.com\/(.*)\/[a-zA-Z0-9]+\/vid\.(flv|
mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i (.*)\.myspacecdn\.(.*)\.footprint\.net\/(.*)\/[a-zA-Z09]+\/vid\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.vimeo\.com\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|
m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.amazonaws\.com\/(.*)\.vimeo\.com(.*)\.(flv|mp4|avi|
mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i v\.imwx\.com\/v\/wxcom\/[a-zA-Z0-9]+\.(flv|mp4|avi|
mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)\?(.*)videoId=[0-9]+&
acl store_id_access_videocache_url url_regex -i c\.wrzuta\.pl\/wv[0-9]+\/[a-z0-9]+/[0-9]+/
acl store_id_access_videocache_url url_regex -i c\.wrzuta\.pl\/wa[0-9]+\/[a-z0-9]+
acl store_id_access_videocache_url url_regex -i cdn[a-z0-9]?[a-z0-9]?[a-z09]?\.public\.extremetube\.phncdn\.com\/(.*)\/[a-zA-Z0-9_-]+\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|
mov|wmv|3gp|mpg|mpeg)

acl store_id_access_videocache_url url_regex -i vs[a-z0-9]?[a-z0-9]?[a-z0-9]?\.hardsextube\.com\/(.*)\/


(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.hardsextube\.com\/videothumbs
acl store_id_access_videocache_url url_regex -i cdn[a-z0-9]?[a-z0-9]?[a-z09]?\.public\.keezmovies\.phncdn\.com\/(.*)\/[0-9a-zA-Z_\-]+\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|
mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i cdn[a-z0-9]?[a-z0-9]?[a-z09]?\.public\.keezmovies\.com\/(.*)\/[0-9a-zA-Z_\-]+\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|
3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i nyc-v[a-z0-9]?[a-z0-9]?[a-z0-9]?\.pornhub\.com\/
(.*)/videos/[0-9]{3}/[0-9]{3}/[0-9]{3}/[0-9]+\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|
mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.video\.pornhub\.phncdn\.com\/videos/(.*)/[0-9]+\.(flv|
mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i video(.*)\.redtubefles\.com\/(.*)\.(flv|mp4|avi|mkv|
mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.slutload-media\.com\/(.*)\/[a-zA-Z0-9_.-]+\.(flv|mp4|
avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i cdn[a-z0-9]?[a-z0-9]?[a-z09]?\.public\.spankwire\.com\/(.*)\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i cdn[a-z0-9]?[a-z0-9]?[a-z09]?\.public\.spankwire\.phncdn\.com\/(.*)\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|
mpg|mpeg)

acl store_id_access_videocache_url url_regex -i \.tube8\.com\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|


m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.xtube\.com\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|
m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url url_regex -i \.xtube\.com\/(.*)(Thumb|videowall)
acl store_id_access_videocache_url url_regex -i \.xvideos\.com\/videos\/flv\/(.*)\/(.*)\.(flv|mp4)
acl store_id_access_videocache_url url_regex -i \.public\.youporn\.phncdn\.com\/(.*)\/[a-zA-Z0-9_-]+\/
(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl store_id_access_videocache_url_dom dstdomain .mccont.com .metacafe.com .redtube.com
.dailymotion.com .fbcdn.net
acl store_id_access_videocache_url_deny_dom dstdomain .download.youporn.com .static.blip.tv
acl dontrewrite url_regex redbot\.org (get_video|videoplayback\?id|videoplayback.*id).*begin\=[1-9]
[0-9]*

#acl speedtest urlpath_regex -i speedtest\/.*\.(jpg|php).*$


#acl speedtest urlpath_regex -i results.php\?.*$
#store_id_access allow speedtest

store_id_access deny !getmethod


store_id_access deny dontrewrite

store_id_access allow store_id_access_videocache_url


store_id_access allow store_id_access_videocache_url_dom
store_id_access allow store_id_access_list_domain_CDN
store_id_access allow store_id_access_list
store_id_access allow store_id_access_list_domain store_id_access_list_path
store_id_access deny all
store_id_program /etc/squid/storeid.pl
store_id_children 30 startup=15 idle=10 concurrency=45

strip_query_terms of

include /etc/squid/refresh.conf

memory_pools of
client_db of
reload_into_ims on
pipeline_prefetch on
offline_mode of

cache_efective_user proxy
cache_efective_group proxy
dns_v4_frst on

request_header_access From deny all


request_header_access Server deny all
request_header_access WWW-Authenticate deny all
request_header_access Link deny all
request_header_access Cache-Control deny all
request_header_access Proxy-Connection deny all
request_header_access X-Cache deny all
request_header_access X-Cache-Lookup deny all
request_header_access Via deny all
request_header_access Forwarded-For deny all
request_header_access X-Forwarded-For deny all
request_header_access Pragma deny all
request_header_access Keep-Alive deny all
vary_ignore_expire on

range_ofset_limit 1 KB

# local
qos_flows local-hit=0x30
# sibling
# qos_flows sibling-hit=0x31
# parent
# qos_flows parent-hit=0x32
# preserve
# qos_flows disable-preserve-miss > /etc/squid/squid.conf

# Konfgurasi Refresh Pattern refresh.conf


touch /etc/squid/refresh.conf
echo
max_stale 4 week

refresh_pattern .*(begin|start)\=[1-9][0-9].* 0 0% 0

refresh_pattern -i (cgi-bin|mrtg|graph) 0 0% 0
#refresh_pattern ^http.*(youtube|googlevideo)\.* 2629742 99% 2629742 ignore-reload overrideexpire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern ^http.*(youtube|googlevideo)\.* 5259487 99% 5259487 ignore-reload override-expire
override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale
#refresh_pattern (get_video\?|videoplayback\?|videodownload\?) 5259487 99% 5259487 overrideexpire ignore-reload ignore-private

refresh_pattern -i ^http:\/\/(.*\.*\.gemscool\.com)\/.*\/.*\/(.*iop?) 10080 99% 10080 ignore-reload


override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale
refresh_pattern -i ^http:\/\/(.*\.*\.gemscool\.com)\/.*\/.*\/(.*zip?) 10080 99% 10080 override-expire
override-lastmod ignore-no-cache ignore-private reload-into-ims ignore-must-revalidate ignore-reload
store-stale

#PATTERN REFRESH
refresh_pattern -i \.(html|htm|css|js|png|jsp|asx|asp|aspx)$ 10080 99% 10080 ignore-reload overrideexpire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern -i \/speedtest\/.*\.(txt|jpg|png|swf) 4320 99% 14400 override-expire ignore-reload
ignore-private ignore-reload override-lastmod reload-into-ims
refresh_pattern .pixieimage\.com.*\.(jp(e?g|e|2)|gif|png|tif?|bmp|swf|mp(4|3)) 1440 99% 14400
override-expire ignore-reload ignore-private ignore-reload override-lastmod reload-into-ims

refresh_pattern .blogspot\.com.*\.(jp(e?g|e|2)|gif|png|tif?|bmp|swf|mp(4|3)) 1440 99% 14400


override-expire ignore-reload ignore-private ignore-reload override-lastmod reload-into-ims
refresh_pattern .multiply\.com.*\.(jp(e?g|e|2)|gif|png|tif?|bmp|swf|mp(4|3)) 1440 99% 14400
override-expire ignore-reload ignore-private ignore-reload override-lastmod reload-into-ims
refresh_pattern .((pikawarnet\.com)|(blogspot\.com)|(pixieimage\.com)|(multiply\.com)).* 60 30% 240
#refresh_pattern -i .google\-analytics\.com.*gif 2629742 99% 2629742 override-expire overridelastmod ignore-no-cache ignore-private reload-into-ims ignore-must-revalidate ignore-reload storestale
refresh_pattern -i ^http:\/\/(.*\.adobe\.com)\/.*\/(.*) 10080 99% 10080 ignore-reload override-expire
override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern -i ^http:\/\/(.*\.google-analytics\.com)\/(__utm\.gif)\?.* 1440 70% 14400 ignore-reload
override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale
refresh_pattern -i ^http:\/\/.*\.softpedia\.com\/dl\/.*\/.*\/.* 26297 99% 43200 ignore-reload overrideexpire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale

#sensitive site
refresh_pattern -i \.(sc-|dl-|ex-|mh-|dll|da-) 0 2% 50 reload-into-ims
refresh_pattern -i \.(mst|Xtp|iop)$ 0 50% 1440 reload-into-ims
refresh_pattern -i (index.php|autoup.exe|main.exe|xtrap.xt|autoupgrade.exe|update.exe|
grandchase.exe|FSLauncher.exe|FreeStyle_Setup.exe|grandchase.exe|flelist.zip)$ 0 50% 1440

refresh_pattern -i (wks_avira-win32-en-pecl.info.gz|wks_avira10-win32-en-pecl.info.gz|
servers.def.vpx)$ 0 50% 1440
refresh_pattern -i (setup.exe.gz|avscan.exe.gz|avguard.exe.gz|flelist.zip|AvaClient.exe) 0 50% 1440
refresh_pattern -i (livescore.com|goal.com|bobet) 0 50% 60

#Windows Update
refresh_pattern -i microsoft.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 43200
reload-into-ims
refresh_pattern -i windowsupdate.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 43200
reload-into-ims
refresh_pattern -i windows.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 43200 reloadinto-ims

#FB
refresh_pattern -i ^http://fbcdn.net.squid.internal 10080 70% 43200 ignore-reload override-expire
override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale

refresh_pattern \.gstatic\.com/images\? 1440 99% 14400 override-expire override-lastmod ignorereload ignore-private ignore-must-revalidate
refresh_pattern \.(akamaihd|edgecastcdn|spilcdn|zgncdn|(tw|y|yt)img)\.com.*\.(jp(e?g|e|2)|gif|png|
swf|mp(3|4)) 10080 99% 10080 override-expire override-lastmod ignore-reload ignore-private

refresh_pattern (gstatic|diggstatic)\.com/.* 10080 99% 10080 override-expire ignore-reload ignoreprivate


refresh_pattern (photobucket|pbsrc|flickr|yimg|ytimg|twimg|gravatar)\.com.*\.(jp(e?g|e|2)|gif|png|
tif?|bmp|swf|mp(4|3)) 10080 99% 10080 override-expire ignore-reload ignore-private
refresh_pattern (ninjasaga|mafawars|cityville|farmville|crowdstar|spilcdn|agame|popcap)\.com/.*
1440 99% 14400 override-expire ignore-reload ignore-private
refresh_pattern ^http:\/\/images|image|img|pics|openx|thumbs[0-9]\. 10080 99% 10080 overrideexpire ignore-reload ignore-private
refresh_pattern ^.*safebrowsing.*google 10080 99% 10080 override-expire ignore-reload ignoreprivate ignore-auth ignore-must-revalidate
refresh_pattern ^http://.*\.squid\.internal\/.* 10080 80% 43200 override-expire override-lastmod
ignore-reload ignore-no-store ignore-must-revalidate ignore-private ignore-auth max-stale=10000
store-stale
refresh_pattern -i c2lo.reverbnation.com 10080 99% 10080 override-expire override-lastmod ignoreno-cache ignore-private ignore-must-revalidate ignore-reload store-stale
refresh_pattern -i ^https:\/\/(.*)\/.*\/(baseballheroes)\/live\/(.*)? 10080 99% 43200 ignore-reload
override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale
refresh_pattern -i ^https:\/\/(dgvbc27jkydqc\.cloudfront\.net)\/.*\/(billiards)\/(.*) 10080 99% 43200
ignore-reload override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store
ignore-auth store-stale

refresh_pattern -i ^https:\/\/(geewa-a\.akamaihd\.net)\/.*\/(.*)\/.*\/(.*) 10080 70% 43200 ignore-reload


override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale
refresh_pattern -i ^https:\/\/(zynga(.*)\.akamaihd\.net)\/(.*)\/.*\/(.*) 10080 70% 43200 ignore-reload
override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale
refresh_pattern -i ^https:\/\/(duapys4lcv8ju\.cloudfront\.net)\/.*\/(.*) 10080 70% 43200 ignore-reload
override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale

#refresh_pattern -i ^http:\/\/(zynga(.*)\.akamaihd\.net)\/(.*)\/.*\/(.*) 10080 99% 43200 ignore-reload


override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale

refresh_pattern -i ^http:\/\/(.*\.flv2\.redtubefles.com)\/(.*)\/(.*)\/(.*)\/(.*) 26297 99% 43200 overrideexpire override-lastmod ignore-no-cache ignore-private ignore-must-revalidate ignore-reload storestale
refresh_pattern -i ^http:\/\/(.*\.thestaticvube\.com)\/.*\/(.*)\/(.*) 26297 99% 43200 override-expire
override-lastmod ignore-no-cache ignore-private ignore-must-revalidate ignore-reload store-stale
refresh_pattern -i ^http:\/\/(.*\.*\.videomega.tv)\/.*\/(.*\.mp4).* 26297 99% 43200 override-expire
override-lastmod ignore-no-cache ignore-private ignore-must-revalidate ignore-reload store-stale
refresh_pattern -i ^http:\/\/(77.247.178.81)\/.*\/(.*\.mp4).* 26297 99% 43200 override-expire
override-lastmod ignore-no-cache ignore-private ignore-must-revalidate ignore-reload store-stale

refresh_pattern -i ^http:\/\/(.*\.dropvideo\.com)\/.*\/(.*\.mp4).* 26297 99% 43200 override-expire


override-lastmod ignore-no-cache ignore-private ignore-must-revalidate ignore-reload store-stale
#refresh_pattern -i ^http:\/\/(.*\.dropvideo\.com)\/.*\/(.*) 26297 99% 43200 override-expire overridelastmod ignore-no-cache ignore-private ignore-must-revalidate ignore-reload store-stale

#ads
refresh_pattern ^.*(streamate.doublepimp.com.*\.js\?|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|gameadvertising\.com|pixel\.quantserve\.com|adperium\.com|doubleclick\.net|
adserving\.cpxinteractive\.com|syndication\.com|media.fastclick.net).* 26297 99% 43200 ignoreprivate override-expire ignore-reload ignore-auth max-stale=43200
refresh_pattern \.(ico|video-stats) 10080 99% 10080 override-expire ignore-reload ignore-private
ignore-auth override-lastmod ignore-must-revalidate
refresh_pattern ^http://((cbk|mt|khm|mlt|tbn)[0-9]?)\.google\.co(m|\.uk|\.id) 10080 99% 10080
override-expire override-lastmod ignore-reload ignore-private ignore-auth ignore-must-revalidate
refresh_pattern vid\.akm\.dailymotion\.com.*\.on2\? 10080 99% 10080 override-expire overridelastmod
refresh_pattern galleries\.video(\?|sz) 5259487 99% 5259487 ignore-reload override-expire overridelastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern \.wikimapia\.org\/? 10080 99% 10080 override-expire override-lastmod ignore-reload
ignore-private

refresh_pattern -i ^http:\/\/(.*\.ads\.contentabc\.com)\/ads\/(.*)\/(.*) 26297 99% 43200 ignore-reload


override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth
store-stale

#general
refresh_pattern -i \.(7z|arj|bin|bz2|cab|dll|exe|gz|inc|iso|jar|lha|ms(i|p|u)|rar|rpm|tar|tgz|zip|rtp|rpz|
nui|kom|stg|pak|sup|nzp|npz|iop)$ 26297 99% 43200 override-expire override-lastmod ignore-private
reload-into-ims ignore-must-revalidate ignore-reload store-stale
refresh_pattern -i \.(class|doc|docx|pdf|pps|ppt|ppsx|pptx|ps|rtx|txt|wpl|xls|xlsx)$ 26297 99% 43200
override-expire override-lastmod ignore-private reload-into-ims ignore-must-revalidate ignore-reload
store-stale
refresh_pattern -i \.(3gp|ac4|agx|au|avi|axd|bmp|cbr|cbt|cbz|dat|divx|flv|gif|hqx|ico|jp(2|e|eg|g)|mid|
mk(a|v)|mov|mp(1|2|3|4|e|eg|g)|og(a|g|v)|qt|ra|ram|rm|swf|tif|tif|wa(v|x)|wm(a|v|x)|x-flv)$ 26297
99% 43200 override-expire override-lastmod ignore-private reload-into-ims ignore-must-revalidate
ignore-reload store-stale
refresh_pattern -i .(html|htm|css|js)$ 26297 99% 43200
refresh_pattern -i .index.(html|htm)$ 26297 99% 43200

refresh_pattern -i \.(3gp|avi|ac4|mp(e?g|a|e|1|2|3|4)|m4(a|v)|3g(p?2|p)|mk(a|v)|og(x|v|a|g|m)|wm(a|
v)|wmx|wpl|rm|snd|vob|wav|asx|avi|qt|divx|flv|f4v|x-flv|dvr-ms|m(1|2)(v|p)|mov|mid|mpeg)$ 43200
100% 43200 ignore-no-store ignore-must-revalidate ignore-private override-expire override-lastmod
reload-into-ims store-stale

refresh_pattern -i \.(7z|ace|rar|jar|gz|tgz|bz2|iso|mod|arj|lha|lzh|zip|tar|cab|dat|pak|kom|zip)$ 10080


80% 10080 ignore-no-store ignore-must-revalidate ignore-private override-expire override-lastmod
reload-into-ims store-stale
refresh_pattern -i \.(jp(e?g|e|2)|gif|pn[pg]|bm?|tif?|ico|swf|css|js|ad)$ 10080 80% 10080 ignore-nostore ignore-must-revalidate ignore-private override-expire override-lastmod reload-into-ims storestale
refresh_pattern -i \.(exe|ms(i|u|p)|deb|bin|ax|r(a|p)m|app|pkg|apk|msi|mar|nzp|iop|xpi|dmg|dds|thor|
nar|gpf)$ 10080 80% 10080 ignore-no-store ignore-must-revalidate ignore-private override-expire
override-lastmod reload-into-ims store-stale
refresh_pattern -i \.(pp(t?x|t)|epub|pdf|rtf|wax|cb(r|z|t)|xl(s?x|s)|do(c?x|c)|inc)$ 10080 80% 10080
ignore-no-store ignore-must-revalidate ignore-private override-expire override-lastmod reload-intoims store-stale

refresh_pattern \.gif$ 26297 99% 43200 ignore-reload override-expire override-lastmod ignore-mustrevalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern \.jpg$ 26297 99% 43200 ignore-reload override-expire override-lastmod ignore-mustrevalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern \.png$ 26297 99% 43200 ignore-reload override-expire override-lastmod ignore-mustrevalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern \.ico$ 26297 99% 43200 ignore-reload override-expire override-lastmod ignore-mustrevalidate ignore-private ignore-no-store ignore-auth store-stale
refresh_pattern \.jpeg$ 26297 99% 43200 ignore-reload override-expire override-lastmod ignoremust-revalidate ignore-private ignore-no-store ignore-auth store-stale

refresh_pattern ^ftp: 40320 20% 40320 override-expire reload-into-ims store-stale


refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern (cgi-bin|\?) 0 0% 0
refresh_pattern . 0 50% 40320 store-stale > /etc/squid/refresh.conf

# Konfgurasi rewriter Storeid.pl


cat > /etc/squid/storeid.pl <<- selesai
#!/usr/bin/perl
#
# storeid.pl with debug opt based on storeurl.pl
# @ http://www2.fh-lausitz.de/launic/comp/misc/squid/projekt_youtube/
#
#

use IO::File;
$|=1;
STDOUT->autoflush(1);

$debug=0; ## recommended:0
$bypassallrules=0; ## recommended:0
$sucks=; ## unused
$sucks=sucks if ($debug>=1);
$timenow=;
$printtimenow=1; ## print timenow: 0|1
my $logfle = /tmp/storeid.log;

open my $logfh, >>, $logfle


or die Couldnt open $logfle for appending: $!\n if $debug;
$logfh->autoflush(1) if $debug;

while (<>) {
$timenow=time(). if ($printtimenow);
print $logfh $timenow.in : $_ if ($debug>=1);
chop;
my $myURL = $_;
@X = split( ,$myURL);

$a = $X[0]; ## channel id
$b = $X[1]; ## url
$c = $X[2]; ## ip address
$u = $b; ## url

if ($bypassallrules){
$out=$u; ## map 1:1

} elsif ($u=~ m/http.*\.(fbcdn|akamaihd)\.net\/h(profle|photos).*[\d\w].*\/([\w]\d+x\d+\/.*\.[\d\w]


{3}).*/) {
$out=OK store-id=http://fbcdn.net.squid.internal/ . $2 . / . $3 ;

} elsif ($u =~ m/^https?:\/\/.*(profle|photo|creative).*\.ak\.fbcdn\.net\/((h|)(profle|photos)-ak-)(snc|


ash|prn)[0-9]?(.*)/) {
$out=OK store-id=http://fbcdn.net.squid.internal/ . $2 . fb . $6 ;

} elsif ($u=~ m/^http(.*)static(.*)(akamaihd|fbcdn).net\/rsrc.php\/(.*\/.*\/(.*).(js|css|png|gif))(\?(.*)|


$)/) {
$out=OK store-id=http://fbcdn.net.squid.internal/static/ . $5 . . . $6 ;

} elsif ($u=~ m/^https?\:\/\/.*utm.gif.*/) {


$out=OK store-id=http://google-analytics.squid.internal/__utm.gif;

#} elsif ($u=~ m/^https?\:\/\/.*\/speedtest\/(.*\.(jpg|txt)).*/) {


# $out=OK store-id=http://speedtest.squid.internal/ . $1 ;

} elsif ($u=~ m/^https?\:\/\/.*\/(.*\..*(mp4|3gp|flv))\?.*/) {


$out=OK store-id=http://video-fle.squid.internal/ . $1 ;

} elsif ($u=~ m/^https?\:\/\/c2lo\.reverbnation\.com\/audio_player\/ec_stream_song\/(.*)\?.*/) {


$out=OK store-id=http://reverbnation.squid.internal/ . $1 ;
} elsif ($u=~ m/^https?\:\/\/.*\.c\.android\.clients\.google\.com\/market\/GetBinary\/GetBinary\/
(.*\/.*)\?.*/) {
$out=OK store-id=http://playstore-android.squid.internal/ . $1 ;

} elsif ($u =~ m/^http:\/\/(videos|photos|scontent)[\-a-z0-9\.]*instagram\.com\/hphotos[\-a-z0-9]*\/


([\w\d\-\_\/\.]*.(mp4|jpg))/){
$out=OK store-id=http://instagram.squid.internal/ . $2 ;

} elsif ($u =~ m/^http:\/\/distilleryimage[\-a-z0-9\.]*instagram\.com\/(.*)/){


$out=OK store-id=http://instagram.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.steampowered\.com\/depot\/[0-9]+\/chunk\/([^\?]*)/){


$out=OK store-id=http://steampowered.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/attachment\.fbsbx\.com\/.*\?(id=[0-9]*).*/) {


$out=OK store-id=http://fbsbx.com.squid.internal/ . $1 ;

} elsif ($u =~ m/^https:\/\/.*\.google\.com\/chrome\/win\/.+\/(.*\.exe)/) {


$out=OK store-id=http://update-google.com.squid.internal/ . $1 ;

} elsif ($x =~ m/^https?:\/\/i[1-4]\.ytimg\.com\/(.*)/) {


$out=OK store-id=http://ytimg.com.squid.internal/ . $1 ;
} elsif ($u =~ m/^https?:\/\/.*fredrive\.com\/download\/[0-9]+\/[0-9]+\/.*\?h=.*e\=.*f\=(.*)\&.*/) {
$out=OK store-id=http://fredrive.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.4shared\.com\/.*\/dlink__[23]F([\w]+)_[23]F(.*)\_3Ftsid_[\w].*/) {


$out=OK store-id=http://4shared.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/.*\.4shared\.com\/download\/([^\/]*).*/) {


$out=OK store-id=http://4shared.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.[a-z]+\.bing\.net\/(.*)\&w=.*/) {


$out=OK store-id=http://bing.squid.internal/ . $1;

} elsif ($u =~ m/^https?:\/\/.*\.bing\.(net|com)\/.*\?id=([a-zA-Z]\.[0-9]+)&pid=.*/) {


$out=OK store-id=http://bing.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/.*\.gstatic\.com\/images\?q=tbn\:(.*)/) {


$out=OK store-id=http://gstatic.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.reverbnation\.com\/.*\/(ec_stream_song|download_song_direct|


stream_song)\/([0-9]*).*/){
$out=OK store-id=http://reverbnation.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/.*\.dl\.sourceforge\.net\/(.*\.(exe|zip|mp3|mp4))/) {


$out=OK store-id=http://sourceforge.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.facebook\.com\/(.*)/) {


$out=OK store-id=http://facebook.com.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/graph\.facebook\.com\/(\w+)\/.*/) {


$out=OK store-id=http://facebook.com.squid.internal/ . $1 ;
} elsif ($u =~ m/^https?:\/\/fs[0-9]+\.flehippo\.com\/[^\/]*\/[^\/]*\/(.*)/) {
$out=OK store-id=http://flehippo.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/download[0-9]+.mediafre\.com\/.*\/\w+\/(.*)/) {


$out=OK store-id=http://mediafre.squid.internal/ .$1 ;

} elsif ($u =~ m/^https?:\/\/.*android\.clients\.google\.com\/[a-z]+\/[a-zA-Z]+\/[a-zA-Z]+\/(.*)\/([09]+)\?.*/) {


$out=OK store-id=http://android.squid.internal/ . $1 . $2 ;

} elsif ($u =~ m/^https?:\/\/.*(googleusercontent.com|blogspot.com)\/(.*)\/([a-z0-9]+)(-[a-z]-[a-z]-[az]+)?\/(.*\.(jpg|png))/) {


$out=OK store-id=http://googleusercontent.squid.internal/ . $5 ;

} elsif ($u =~ m/^https?:\/\/global-shared-fles-[a-z][0-9]\.softonic\.com\/.{3}\/.{3}\/.*\/.*\=(.*\.exe)/)


{
$out=OK store-id=http://softonic.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*netmarble\.co\.id\/.*\/(data|ModooMarble)\/(.*)/) {


$out=OK store-id=http://netmarble.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/(.*)\.windowsupdate\.com\/(.*)\/(.*)\/([a-z].*)/) {


$out=OK store-id=http://windowsupdate.squid.internal/ . $4 ;

} elsif ($u =~ m/^https?:\/\/.*fletrip\.net\/.*\/((.*)\.([^\/\?\&]{2,4}))\?.*$/) {


$out=OK store-id=http://fletrip.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*get4mobile\.net\/.*f=([^\/\?\&]*).*$/) {

$out=OK store-id=http://get4mobile.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*thestaticvube\.com\/.*\/(.*)/) {


$out=OK store-id=http://thestaticvube.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/113\.6\.235\.171\/youku\/.*\/(.*\.flv)/) {


$out=OK store-id=http://youku.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/\d+\.\d+\.\d+\.\d+\/drama\/(.*\.mp4)\?.*\=(\d+)/) {


$out=OK store-id=http://drama.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/([a-z])[\d]{1,2}?(.gstatic\.com.*|\.wikimapia\.org.*)/) {


$out=OK store-id=http://gstatic.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.[a-z][0-9]\.(tiles\.virtualearth\.net)\/(.*\&n=z)/) {


$out=OK store-id=http://virtualearth.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/imgv2-[0-9]\.scribdassets\.com\/(.*)/) {

$out=OK store-id=http://scribdassets.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/(.*?)\/(archlinux\/[a-zA-Z].*\/os\/.*)/) {


$out=OK store-id=http://archlinux.squid.internal/ . $1 ;

#} elsif ($u =~ m/^https?:\/\/(.*?)\/speedtest\/(.*\.(jpg|txt))\??.*$/) {


# $out=OK store-id=http://speedtest.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/i[1-9]{3}\.photobucket\.com\/(.*)/) {


$out=OK store-id=http://photobucket.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/i[1-9]{4}\.photobucket\.com\/(.*)/) {


$out=OK store-id=http://photobucket.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/avideos\.5min\.com\/.*\/(.*)\?.*/) {


$out=OK store-id=http://avideos.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.catalog\.video\.msn\.com\/.*\/(.*\.(mp4|flv|m4v))/) {

$out=OK store-id=http://msn-video.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/v\.imwx\.com\/.*\/(.*)\?.*/) {


$out=OK store-id=http://imwx.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/video[0-9]\.break\.com\/.*\/(.*)\?.*/) {


$out=OK store-id=http://break.squid.internal/ .$1 ;

} elsif ($u =~ m/^https?:\/\/.*\.video[0-9]\.blip\.tv\/.*\/(.*)\?.*/) {


$out=OK store-id=http://blip.squid.internal/ .$1 ;

} elsif ($u =~ m/^https?:\/\/ss[0-9]\.vidivodo\.com\/vidivodo\/vidservers\/server[0-9]*\/videos\/.*\/([azA-Z0-9.]*)\?.*/) {


$out=OK store-id=http://vidivodo.squid.internal/ .$1 ;

} elsif ($u =~ m/^https?:\/\/video\-http\.media\-imdb\.com\/([a-zA-Z0-9\@\_\-]+\.(mp4|flv|m4v))\?.*/)


{
$out=OK store-id=http://imdb-video.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/(vl|v)\.mccont\.com\/(.*)\/(.*\.(mp4|m4v|flv))\?.*/) {


$out=OK store-id=http://mccont.squid.internal/ . $3 ;

} elsif ($u =~ m/^https?:\/\/(vid.{0,2}|proxy.*)(\.ak|\.ec|\.akm|)\.(dmcdn\.net|dailymotion\.com)\/.*\/


(frag.*\.(flv|mp4|m4v)).*/) {
$out=OK store-id=http://dailymotion.squid.internal/ . $4 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.vimeo[^\/]*\.com.*\/([[^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|


mov|wmv|3gp|mpg|mpeg|web))\?.*/) {
$out=OK store-id=http://vimeo.squid.internal/ .$1 ;

} elsif ($u =~ m/^https?:\/\/fcache\.veoh\.com\/.*\/.*(l[0-9]*\.(mp4|flv))\?.*/) {


$out=OK store-id=http://veoh.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/video\.thestaticvube\.com\/.*\/(.*)/) {


$out=OK store-id=http://thestaticvube.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/cdn[0-9]\.videos\.videobash\.com\/.*\/(.*\.(mp4|m4v|flv))\?.*/) {


$out=OK store-id=http://videobash.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.phncdn[^\/]*\.com.*\/([[^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|


m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://phncdn.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.xvideos\.com\/.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|


wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://xvideos.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.tube8[^\/]*\.com.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|


mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://tube8.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.(redtube|redtubefles)\.com\/.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|


rmvb|m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://redtube.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/.*\/xh.*\/([^\/]*\.(flv|mp4|avi|mkv|


mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg))/) {
$out=OK store-id=http://xhcdn.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.xhcdn[^\/]*\.com.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|


mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://xhcdn.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.nsimg[^\/]*\.net.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|


mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://nsimg.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.youjizz\.com.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|


3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://youjizz.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.public\.keezmovies[^\/]*\.com.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|


rmvb|m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://keezmovies.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.youporn[^\/]*\.com.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|


m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://youporn.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.spankwire[^\/]*\.com.*\/([^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|


m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://spankwire.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.pornhub[^\/]*\.com.*\/([[^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|


m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://pornhub.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.us.playvid[^\/]*\.com.*\/([[^\/]*\.(flv|mp4|avi|mkv|mp3|rm|rmvb|


m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://playvid.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.slutload-media[^\/]*\.com.*\/([[^\/]*\.(flv|mp4|avi|mkv|mp3|rm|


rmvb|m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://slutload-media.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.hardsextube[^\/]*\.com.*\/([[^\/]*\.(flv|mp4|avi|mkv|mp3|rm|


rmvb|m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://hardsextube.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*\.public\.extremetube[^\/]*\.com.*\/([[^\/]*\.(flv|mp4|avi|mkv|mp3|


rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg))\?.*/) {
$out=OK store-id=http://extremetube.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/([a-z0-9.]*)(\.doubleclick\.net|\.quantserve\.com|.exoclick\.com|


interclick.\com|\.googlesyndication\.com|\.auditude\.com|.visiblemeasures\.com|yieldmanager|
cpxinteractive)(.*)/) {
$out=OK store-id=http://ads.squid.internal/ . $3 ;

} elsif ($u =~ m/^https?:\/\/(.*?)\/(ads)\?(.*?)/) {


$out=OK store-id=http://ads.squid.internal/ .$3 ;

} elsif ($u =~ m/^https?:\/\/[^\/]*phobos\.apple\.com\/.*\/([^\/]*\.ipa)/) {


$out=OK store-id=http://apple.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/fs\w*\.fleserve\.com\/fle\/(\w*)\/[\w-]*\.\/(.*)/) {


$out=OK store-id=http://fleserve.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/s[0-9]*\.flesonic\.com\/download\/([0-9]*)\/(.*)/) {


$out=OK store-id=http://flesonic.squid.internal/ . $2 ;

} elsif ($u =~ m/^https?:\/\/download[0-9]{3}\.avast\.com\/(.*)/) {


$out=OK store-id=http://avast.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+x\.[a-z]\.avast\.com\/[a-zA-Z0-9]+x\/(.*\.vpx)/)


{
$out=OK store-id=http://avast.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/(iavs.*)/) {


$out=OK store-id=http://iavs.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/.*\.starhub\.com\/[a-z]+\/[a-z]+\/[a-z]+\/(.*exe)\?[0-9]/) {


$out=OK store-id=http://starhub.squid.internal/ . $1 ;

} elsif ($u =~ m/^https?:\/\/dnl-[0-9]{2}\.geo\.kaspersky\.com\/(.*)/) {


$out=OK store-id=http://kaspersky.squid.internal/ . $1 ;

} elsif ($u=~ m/^https?\:\/\/.*youtube.*ptracking.*/){


@video_id = m/[&?]video_id\=([^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
unless (-e /tmp/@cpn){
open FILE, >/tmp/@cpn;
print FILE @video_id;
close FILE;
}
$out=ERR;

} elsif ($u=~ m/^https?\:\/\/.*youtube.*stream_204.*/){


@docid = m/[&?]docid\=([^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
unless (-e /tmp/@cpn){
open FILE, >/tmp/@cpn;
print FILE @docid;
close FILE;
}

$out=ERR;

} elsif ($u=~ m/^https?\:\/\/.*youtube.*player_204.*/){


@v = m/[&?]v\=([^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
unless (-e /tmp/@cpn){
open FILE, >/tmp/@cpn;
print FILE @v;
close FILE;
}
$out=ERR;

} elsif ($u=~ m/^https?\:\/\/.*(youtube|googlevideo).*videoplayback.*/){


@itag = m/[&?](itag\=[0-9]*)/;
@range = m/[&?](range\=[^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
@mime = m/[&?](mime\=[^\&\s]*)/;
@id = m/[&?]id\=([^\&\s]*)/;

if (defned(@cpn[0])){
if (-e /tmp/@cpn){
open FILE, /tmp/@cpn;
@id = <FILE>;
close FILE;}
}
$out=OK store-id=http://video-srv.squid.internal/id=@id@mime@range;

} else {
$out=ERR;
}
print $logfh $timenow.out: $a $out\n if ($debug>=1);
print $a $out\n;
}
close $logfh if ($debug);
selesai

chmod +x /etc/squid/storeid.pl

# Konfgurasi Startup Service Squid


cat > /etc/init.d/squid <<-fnis
#!/bin/sh
#
# squid32012 Startup script for the SQUID HTTP proxy-cache.
#
# Version: @(#)squid3.rc 1.0 07-Jul-2006 kalpin@debian.org
#
### BEGIN INIT INFO
# Provides: Squid 3.5.7
# File-Location: /etc/init.d/squid
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Should-Start: $named
# Should-Stop: $named
# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6
# Short-Description: Squid HTTP Proxy version 3.5.7
### END INIT INFO

NAME=squid
DESC=Squid HTTP Proxy 3.5.7 imxpert.co
DAEMON=/usr/sbin/squid
PIDFILE=/var/run/$NAME.pid
CONFIG=/etc/squid/squid.conf
SQUID_ARGS=-YC -f $CONFIG
# RAMFS=/scripts/ramcache

[ ! -f /etc/default/squid ] || . /etc/default/squid

. /lib/lsb/init-functions

PATH=/bin:/usr/bin:/sbin:/usr/sbin

[ -x $DAEMON ] || exit 0

ulimit -n 65535

fnd_cache_dir () {
w= # space tab
res=`sed -ne
s/^$1[$w]\+[^'$w]\+[$w]\+\([^'$w]\+\).*$/\1/p;
t end;
d;
:end q < $CONFIG`
[ -n $res ] || res=$2
echo $res
}

fnd_cache_type () {
w= # space tab
res=`sed -ne

s/^$1[$w]\+\([^'$w]\+\).*$/\1/p;
t end;
d;
:end q < $CONFIG`
[ -n $res ] || res=$2
echo $res
}

start () {
# $RAMFS clean
# $RAMFS mount
# $RAMFS restore

cache_dir=`fnd_cache_dir cache_dir /cache`


cache_type=`fnd_cache_type cache_dir aufs`

#
# Create spool dirs if they dont exist.

#
if [ $cache_type = coss -a -d $cache_dir -a ! -f $cache_dir/stripe ] || [ $cache_type !=
coss -a -d $cache_dir -a ! -d $cache_dir/00 ]
then
log_warning_msg Creating $DESC cache structure
$DAEMON -z
f

umask 027
ulimit -n 65535

cd $cache_dir
start-stop-daemon quiet start \
pidfle $PIDFILE \
exec $DAEMON $SQUID_ARGS < /dev/null
return $?
}

stop () {

PID=`cat $PIDFILE 2>/dev/null`


start-stop-daemon stop quiet pidfle $PIDFILE exec $DAEMON
#
# Now we have to wait until squid has _really_ stopped.
#
sleep 2
if test -n $PID && kill -0 $PID 2>/dev/null
then
log_action_begin_msg Waiting
cnt=0
while kill -0 $PID 2>/dev/null
do
cnt=`expr $cnt + 1`
if [ $cnt -gt 24 ]
then
log_action_end_msg 1

return 1
f
sleep 5
log_action_cont_msg
done
log_action_end_msg 0
return 0
else
return 0
f
}

case $1 in
start)
log_daemon_msg Starting $DESC $NAME
if start ; then
log_end_msg $?
else

log_end_msg $?
f
;;
stop)
log_daemon_msg Stopping $DESC $NAME
if stop ; then
log_end_msg $?
else
log_end_msg $?
f
# $RAMFS dump
# $RAMFS umount
# $RAMFS clean

;;
reload|force-reload)
log_action_msg Reloading $DESC confguration fles
start-stop-daemon stop signal 1 \

pidfle $PIDFILE quiet exec $DAEMON


log_action_end_msg 0
;;
restart)
log_daemon_msg Restarting $DESC $NAME
stop
if start ; then
log_end_msg $?
else
log_end_msg $?
f
;;
*)
echo Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart}
exit 3
;;
esac
exit 0

fnis

# Set Permission dan restart daemon Squid


chmod +x /etc/init.d/squid
update-rc.d -f squid defaults
/etc/init.d/squid stop
chown -R proxy.proxy /cache*
mkdir -p /var/log/squid
chown -R proxy.proxy /var/log/squid*
squid -z
clear
/etc/init.d/squid restart

# Set iproute dan iptables untuk tproxy


echo Setup iptables dan ip route
sleep 2

echo up ip rule add fwmark 1 lookup 100

up ip route add local 0.0.0.0/0 dev lo table 100


up iptables-restore < /etc/network/iptables.tproxy >> /etc/network/interfaces

ip rule add fwmark 1 lookup 100


ip route add local 0.0.0.0/0 dev lo table 100

iptables -X
iptables -F -t mangle
iptables -t mangle -N DIVERT
iptables -t mangle -A DIVERT -j MARK set-mark 1
iptables -t mangle -A DIVERT -j ACCEPT
iptables -t mangle -A INPUT -j ACCEPT
iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
iptables -t mangle -A PREROUTING -d $IPSERV -p tcp dport 80 -j ACCEPT
iptables -t mangle -A PREROUTING -d $IPSERV -p tcp dport 8080 -j ACCEPT
iptables -t mangle -A PREROUTING -d $IPSERV -p tcp dport 3128 -j ACCEPT
iptables -t mangle -m multiport -A PREROUTING ! -d $IPSERV -p tcp dports 80 -j TPROXY tproxymark 0x1/0x1 on-port 3129

iptables-save > /etc/network/iptables.tproxy

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy