1# Installing SQUID / LUSCA in UBUNTU
4 | tar xzvf LUSCA_HEAD-r14809.tar.gz |
Update & Install some tools for ubuntu
2 | sudo apt-get install gcc build-essential sharutils ccze libzip-dev automake1.9 |
Now compile LUSCA with following options
1 | ./configure
'--prefix=/usr/local/squid' '--enable-removal-policies=heap,lru'
'--disable-dependency-tracking' '--disable-arp-acl'
'--disable-cache-digests' '--enable-cachemgr-hostname=localhost'
'--disable-delay-pools' '--enable-epoll'
'--enable-external-acl-helpers=ip_user' '--disable-ident-lookups'
'--enable-linux-netfilter' '--disable-referer-log'
'--enable-removal-policies=heap,lru' '--disable-snmp' '--disable-ssl'
'--enable-storeio=aufs,null,coss' '--disable-useragent-log'
'--disable-wccpv2' '--with-aio' '--with-maxfd=1048576' '--with-dl'
'--with-pthreads' 'build_alias=i686-redhat-linux-gnu'
'host_alias=i686-redhat-linux-gnu'
'targe_alias=i686-redhat-linux-gnu''--enable-truncate'
'--disable-unlinkd' '--with-large-files' '--disable-htcp' |
All of
Lusca/Squid configuration files can be found at
/usr/local/squid/etc/
and squid executable can be found at
/usr/local/squid/sbin/
Now We will edit
squid.
conf file to make it customize according to our requirements by . . .
1 | nano /usr/local/squid/etc/squid.conf |
Delete all previously lines , and paste the following lines.
Remember following
squid.
conf is
not very neat and clean , you will find many un necessary junk entries
in it, but as I didn’t had time to clean them all, so you may clean them
as per your targets and goals.
001 | # SQUID 2.7/ LUSCA TEST CONFIG FILE |
002 | # Email: aacable@hotmail.com |
005 | # PORT and Transparent Option |
006 | http_port 8080 transparent |
010 | # Cache Directory , modify it according to your system. |
011 | # but first create directory in root by mkdir /cache1 |
012 | # and then issue this command chown proxy:proxy /cache1 |
013 | # [for ubuntu user is proxy, in Fedora user is SQUID] |
014 | # I have set 500 MB for caching reserved just for caching , |
015 | # adjust it according to your need. |
016 | # My recommendation is to have one cache_dir per drive. zzz |
018 | #store_dir_select_algorithm round-robin |
019 | cache_dir aufs /cache1 500 16 256 |
020 | cache_replacement_policy heap LFUDA |
021 | memory_replacement_policy heap LFUDA |
023 | # If you want to enable DATE time n SQUID Logs,use following |
025 | logformat squid %tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt |
028 | # How much days to keep users access web logs |
029 | # You need to rotate your log files with a cron job. For example: |
030 | # 0 0 * * * /usr/local/squid/bin/squid -k rotate |
033 | cache_access_log /var/log/squid/access.log |
034 | cache_log /var/log/squid/cache.log |
035 | cache_store_log /var/log/squid/store.log |
037 | #I used DNSAMSQ service for fast dns resolving |
038 | #so install by using "apt-get install dnsmasq" first |
039 | dns_nameservers 127.0.0.1 221.132.112.8 |
046 | acl all src 0.0.0.0/0.0.0.0 |
047 | acl manager proto cache_object |
048 | acl localhost src 127.0.0.1/255.255.255.255 |
049 | acl to_localhost dst 127.0.0.0/8 |
050 | acl SSL_ports port 443 563 # https, snews |
051 | acl SSL_ports port 873 # rsync |
052 | acl Safe_ports port 80 # http |
053 | acl Safe_ports port 21 # ftp |
054 | acl Safe_ports port 443 563 # https, snews |
055 | acl Safe_ports port 70 # gopher |
056 | acl Safe_ports port 210 # wais |
057 | acl Safe_ports port 1025-65535 # unregistered ports |
058 | acl Safe_ports port 280 # http-mgmt |
059 | acl Safe_ports port 488 # gss-http |
060 | acl Safe_ports port 591 # filemaker |
061 | acl Safe_ports port 777 # multiling http |
062 | acl Safe_ports port 631 # cups |
063 | acl Safe_ports port 873 # rsync |
064 | acl Safe_ports port 901 # SWAT |
065 | acl purge method PURGE |
066 | acl CONNECT method CONNECT |
067 | http_access allow manager localhost |
068 | http_access deny manager |
069 | http_access allow purge localhost |
070 | http_access deny purge |
071 | http_access deny !Safe_ports |
072 | http_access deny CONNECT !SSL_ports |
073 | http_access allow localhost |
075 | http_reply_access allow all |
078 | #========================== |
079 | # Administrative Parameters |
080 | #========================== |
082 | # I used UBUNTU so user is proxy, in FEDORA you may use use squid |
083 | cache_effective_user proxy |
084 | cache_effective_group proxy |
085 | cache_mgr aacable@hotmail.com |
086 | visible_hostname proxy.aacable.net |
087 | unique_hostname aacable@hotmail.com |
092 | half_closed_clients off |
101 | max_filedescriptors 65536 |
106 | # If you want to hide your proxy machine from being detected at various site use following |
109 | #============================================ |
110 | # OPTIONS WHICH AFFECT THE CACHE SIZE / zaib |
111 | #============================================ |
112 | # If you have 4GB memory in Squid box, we will use formula of 1/3 |
113 | # You can adjust it according to your need. IF squid is taking too much of RAM |
114 | # Then decrease it to 128 MB or even less. |
117 | minimum_object_size 0 bytes |
118 | maximum_object_size 100 MB |
119 | maximum_object_size_in_memory 128 KB |
121 | #============================================================$ |
122 | # SNMP , if you want to generate graphs for SQUID via MRTG |
123 | #============================================================$ |
124 | #acl snmppublic snmp_community gl |
126 | #snmp_access allow snmppublic all |
127 | #snmp_access allow all |
129 | #============================================================ |
130 | # ZPH , To enable cache content to be delivered at full lan speed, |
131 | # To bypass the queue at MT. |
132 | #============================================================ |
133 | tcp_outgoing_tos 0x30 all |
140 | acl videocache_allow_url url_regex -i \.youtube\.com\/get_video\? |
141 | acl videocache_allow_url url_regex -i \.youtube\.com\/videoplayback \.youtube\.com\/videoplay \.youtube\.com\/get_video\? |
142 | acl
videocache_allow_url url_regex -i \.youtube\.[a-z][a-z]\/videoplayback
\.youtube\.[a-z][a-z]\/videoplay \.youtube\.[a-z][a-z]\/get_video\? |
143 | acl
videocache_allow_url url_regex -i \.googlevideo\.com\/videoplayback
\.googlevideo\.com\/videoplay \.googlevideo\.com\/get_video\? |
144 | acl videocache_allow_url url_regex -i \.google\.com\/videoplayback \.google\.com\/videoplay \.google\.com\/get_video\? |
145 | acl
videocache_allow_url url_regex -i \.google\.[a-z][a-z]\/videoplayback
\.google\.[a-z][a-z]\/videoplay \.google\.[a-z][a-z]\/get_video\? |
146 | acl videocache_allow_url url_regex -i proxy[a-z0-9\-][a-z0-9][a-z0-9][a-z0-9]?\.dailymotion\.com\/ |
147 | acl videocache_allow_url url_regex -i vid\.akm\.dailymotion\.com\/ |
148 | acl videocache_allow_url url_regex -i [a-z0-9][0-9a-z][0-9a-z]?[0-9a-z]?[0-9a-z]?\.xtube\.com\/(.*)flv |
149 | acl videocache_allow_url url_regex -i \.vimeo\.com\/(.*)\.(flv|mp4) |
150 | acl videocache_allow_url url_regex -i va\.wrzuta\.pl\/wa[0-9][0-9][0-9][0-9]? |
151 | acl videocache_allow_url url_regex -i \.youporn\.com\/(.*)\.flv |
152 | acl videocache_allow_url url_regex -i \.msn\.com\.edgesuite\.net\/(.*)\.flv |
153 | acl videocache_allow_url url_regex -i \.tube8\.com\/(.*)\.(flv|3gp) |
154 | acl videocache_allow_url url_regex -i \.mais\.uol\.com\.br\/(.*)\.flv |
155 | acl videocache_allow_url url_regex -i \.blip\.tv\/(.*)\.(flv|avi|mov|mp3|m4v|mp4|wmv|rm|ram|m4v) |
156 | acl videocache_allow_url url_regex -i \.apniisp\.com\/(.*)\.(flv|avi|mov|mp3|m4v|mp4|wmv|rm|ram|m4v) |
157 | acl videocache_allow_url url_regex -i \.break\.com\/(.*)\.(flv|mp4) |
158 | acl videocache_allow_url url_regex -i redtube\.com\/(.*)\.flv |
159 | acl videocache_allow_dom dstdomain .mccont.com .metacafe.com .cdn.dailymotion.com |
160 | acl videocache_deny_dom dstdomain .download.youporn.com .static.blip.tv |
161 | acl dontrewrite url_regex redbot\.org \.php |
162 | acl getmethod method GET |
164 | storeurl_access deny dontrewrite |
165 | storeurl_access deny !getmethod |
166 | storeurl_access deny videocache_deny_dom |
167 | storeurl_access allow videocache_allow_url |
168 | storeurl_access allow videocache_allow_dom |
169 | storeurl_access deny all |
171 | storeurl_rewrite_program /etc/squid/storeurl.pl |
172 | storeurl_rewrite_children 7 |
173 | storeurl_rewrite_concurrency 100 |
175 | acl store_rewrite_list urlpath_regex -i \/(get_video\?|videodownload\?|videoplayback.*id) |
176 | acl store_rewrite_list urlpath_regex -i \.flv$ \.mp3$ \.mp4$ \.swf$ \ |
177 | storeurl_access allow store_rewrite_list |
178 | storeurl_access deny all |
180 | refresh_pattern
-i \.flv$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
181 | refresh_pattern
-i \.mp3$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
182 | refresh_pattern
-i \.mp4$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
183 | refresh_pattern
-i \.swf$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
184 | refresh_pattern
-i \.gif$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
185 | refresh_pattern
-i \.jpg$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
186 | refresh_pattern
-i \.jpeg$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
187 | refresh_pattern
-i \.exe$ 10080 80% 10080 override-expire override-lastmod
reload-into-ims ignore-reload ignore-no-cache ignore-private
ignore-auth |
189 | # 1 year = 525600 mins, 1 month = 10080 mins, 1 day = 1440 |
190 | refresh_pattern
(get_video\?|videoplayback\?|videodownload\?|\.flv?) 10080 80% 10080
ignore-no-cache ignore-private override-expire override-lastmod
reload-into-ims |
191 | refresh_pattern
(get_video\?|videoplayback\?id|videoplayback.*id|videodownload\?|\.flv?)
10080 80% 10080 ignore-no-cache ignore-private override-expire
override-lastmod reload-into-ims |
192 | refresh_pattern
\.(ico|video-stats) 10080 80% 10080 override-expire ignore-reload
ignore-no-cache ignore-private ignore-auth override-lastmod
negative-ttl=10080 |
193 | refresh_pattern \.etology\? 10080 80% 10080 override-expire ignore-reload ignore-no-cache |
194 | refresh_pattern galleries\.video(\?|sz) 10080 80% 10080 override-expire ignore-reload ignore-no-cache |
195 | refresh_pattern brazzers\? 10080 80% 10080 override-expire ignore-reload ignore-no-cache |
196 | refresh_pattern \.adtology\? 10080 80% 10080 override-expire ignore-reload ignore-no-cache |
197 | 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).*
10080 20% 10080 ignore-no-cache ignore-private override-expire
ignore-reload ignore-auth negative-ttl=40320 max-stale=10 |
198 | refresh_pattern
^.*safebrowsing.*google 10080 80% 10080 override-expire ignore-reload
ignore-no-cache ignore-private ignore-auth negative-ttl=10080 |
199 | refresh_pattern ^http://((cbk|mt|khm|mlt)[0-9]?)\.google\.co(m|\.uk) 10080 80% 10080 override-expire ignore-reload ignore-private negative-ttl=10080 |
200 | refresh_pattern ytimg\.com.*\.jpg 10080 80% 10080 override-expire ignore-reload |
201 | refresh_pattern images\.friendster\.com.*\.(png|gif) 10080 80% 10080 override-expire ignore-reload |
202 | refresh_pattern garena\.com 10080 80% 10080 override-expire reload-into-ims |
203 | refresh_pattern photobucket.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png) 10080 80% 10080 override-expire ignore-reload |
204 | refresh_pattern
vid\.akm\.dailymotion\.com.*\.on2\? 10080 80% 10080
ignore-no-cache override-expire override-lastmod |
205 | refresh_pattern
mediafire.com\/images.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png) 10080 80%
10080 reload-into-ims override-expire ignore-private |
206 | refresh_pattern
^http:\/\/images|pics|thumbs[0-9]\. 10080 80% 10080
reload-into-ims ignore-no-cache ignore-reload override-expire |
207 | refresh_pattern
^http:\/\/www.onemanga.com.*\/ 10080 80% 10080
reload-into-ims ignore-no-cache ignore-reload override-expire |
208 | refresh_pattern ^http://v\.okezone\.com/get_video\/([a-zA-Z0-9])
10080 80% 10080 override-expire ignore-reload ignore-no-cache
ignore-private ignore-auth override-lastmod negative-ttl=10080 |
211 | refresh_pattern
-i \.facebook.com.*\.(jpg|png|gif) 10080 80% 10080
ignore-reload override-expire ignore-no-cache |
212 | refresh_pattern
-i \.fbcdn.net.*\.(jpg|gif|png|swf|mp3) 10080 80% 10080
ignore-reload override-expire ignore-no-cache |
213 | refresh_pattern
static\.ak\.fbcdn\.net*\.(jpg|gif|png) 10080 80% 10080
ignore-reload override-expire ignore-no-cache |
214 | refresh_pattern
^http:\/\/profile\.ak\.fbcdn.net*\.(jpg|gif|png) 10080 80% 10080
ignore-reload override-expire ignore-no-cache |
217 | refresh_pattern
-i \.(3gp|7z|ace|asx|bin|deb|divx|dvr-ms|ram|rpm|exe|inc|cab|qt)
10080 80% 10080 ignore-no-cache override-expire override-lastmod
reload-into-ims |
218 | refresh_pattern
-i \.(rar|jar|gz|tgz|bz2|iso|m1v|m2(v|p)|mo(d|v)|arj|lha|lzh|zip|tar)
10080 80% 10080 ignore-no-cache override-expire override-lastmod
reload-into-ims |
219 | refresh_pattern
-i \.(jp(e?g|e|2)|gif|pn[pg]|bm?|tiff?|ico|swf|dat|ad|txt|dll)
10080 80% 10080 ignore-no-cache override-expire override-lastmod
reload-into-ims |
220 | 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)
10080 80% 10080 ignore-no-cache override-expire override-lastmod
reload-into-ims |
221 | 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)
10080 80% 10080 ignore-no-cache override-expire override-lastmod
reload-into-ims |
223 | refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 |
224 | refresh_pattern ^gopher: 1440 0% 1440 |
225 | refresh_pattern ^ftp: 10080 95% 10080 override-lastmod reload-into-ims |
226 | refresh_pattern . 1440 95% 10080 override-lastmod reload-into-ims |
Now create
cache dir and
logs files , and assign them necessary permissions.
2 | chown proxy:proxy /cache1 |
4 | chmod 777 /var/log/squid |
Now initialize
cache dir by
1 | /usr/local/squid/sbin/squid -z |
SOTEURL.PL
Now We have to create an important file name
storeurl.pl , which is very important and actually it does the
main job to pull video from cache.
2 | touch /etc/squid/storeurl.pl |
3 | chmod +x /etc/squid/storeurl.pl |
4 | nano /etc/squid/storeurl.pl |
Now paste the following lines, then Save and exit.
002 | # This script is NOT written or modified by me, I only copy pasted it from the internet. |
003 | # It was First originally Writen by chudy_fernandez@yahoo.com |
004 | # & Have been modified by various persons over the net to fix/add various functions. |
005 | # For Example this ver was modified by member of comstuff.net to satisfy common and dynamic content. |
006 | # th30nly @comstuff.net a.k.a invisible_theater , |
011 | # $X[1] =~ s/&sig=.*//; |
017 | if (m/^http:\/\/(.*)\/speedtest\/(.*\.(jpg|txt))\?(.*)/) { |
021 | }elsif (m/^http:\/\/199\.91\.15\d\.\d*\/\w{12}\/(\w*)\/(.*)/) { |
025 | }elsif (m/^http:\/\/fs\w*\.fileserve\.com\/file\/(\w*)\/[\w-]*\.\/(.*)/) { |
029 | }elsif (m/^http:\/\/s[0-9]*\.filesonic\.com\/download\/([0-9]*)\/(.*)/) { |
033 | }elsif (m/^http:\/\/[a-zA-Z]{2}\d*\.4shared\.com(:8080|)\/download\/(.*)\/(.*\..*)\?.*/) { |
037 | }elsif
(m/^http:\/\/[a-zA-Z]{2}\d*\.4shared\.com(:8080|)\/img\/(\d*)\/\w*\/dlink__2Fdownload_2F(\w*)_3Ftsid_3D[\w-]*\/preview\.mp3\?sId=\w*/)
{ |
040 | #photos-X.ak.fbcdn.net where X a-z |
041 | }elsif (m/^http:\/\/photos-[a-z](\.ak\.fbcdn\.net)(\/.*\/)(.*\.jpg)/) { |
044 | #YX.sphotos.ak.fbcdn.net where X 1-9, Y a-z |
045 | } elsif (m/^http:\/\/[a-z][0-9]\.sphotos\.ak\.fbcdn\.net\/(.*)\/(.*)/) { |
049 | } elsif (m/^http:\/\/(cbk|mt|khm|mlt|tbn)[0-9]?(.google\.co(m|\.uk|\.id).*)/) { |
050 | print $x . "http://" . $1 . $2 . "\n"; |
052 | # compatibility for old cached get_video?video_id |
053 | }
elsif
(m/^http:\/\/([0-9.]{4}|.*\.youtube\.com|.*\.googlevideo\.com|.*\.video\.google\.com).*?(videoplayback\?id=.*?|video_id=.*?)\&(.*?)/)
{ |
054 | $z = $2; $z =~ s/video_id=/get_video?video_id=/; |
058 | } elsif (m/^http:\/\/([0-9.]{4}|.*\.youtube\.com|.*\.googlevideo\.com|.*\.video\.google\.com)\/videoplayback\?(.*)/) { |
064 | if ($p_str =~ m/(itag=[0-9]*)/){$tag = "&".$1} |
065 | if ($p_str =~ m/(algorithm=[a-z]*\-[a-z]*)/){$alg = "&".$1} |
066 | if ($p_str =~ m/(id=[a-zA-Z0-9]*)/){$id = "&".$1} |
067 | if ($p_str =~ m/(range=[0-9\-]*)/){$range = "&".$1; $range =~ s/-//; $range =~ s/range=//; } |
070 | } elsif (m/^http:\/\/www\.google-analytics\.com\/__utm\.gif\?.*/) { |
073 | #Cache High Latency Ads |
074 | }
elsif
(m/^http:\/\/([a-z0-9.]*)(\.doubleclick\.net|\.quantserve\.com|\.googlesyndication\.com|yieldmanager|cpxinteractive)(.*)/)
{ |
078 | s/activity;.*/activity/; |
081 | s/;×tamp=[0-9]*//; |
082 | s/[&?]correlator=[0-9]*//; |
087 | # s/&prev_slotnames=[^&]*// |
092 | s/(&alternate_ad_url=http%3A%2F%2F[^(%2F)]*)[^&]*/\1/; |
093 | s/(&url=http%3A%2F%2F[^(%2F)]*)[^&]*/\1/; |
094 | s/(&ref=http%3A%2F%2F[^(%2F)]*)[^&]*/\1/; |
095 | s/(&cookie=http%3A%2F%2F[^(%2F)]*)[^&]*/\1/; |
103 | s/&page_slots=[^&]*//; |
105 | print $x . "http://" . $1 . $2 . $y . "\n"; |
107 | #cache high latency ads |
108 | } elsif (m/^http:\/\/(.*?)\/(ads)\?(.*?)/) { |
109 | print $x . "http://" . $1 . "/" . $2 . "\n"; |
111 | # spicific servers starts here.... |
112 | } elsif (m/^http:\/\/(www\.ziddu\.com.*\.[^\/]{3,4})\/(.*?)/) { |
113 | print $x . "http://" . $1 . "\n"; |
115 | #cdn, varialble 1st path |
116 | } elsif (($u =~ /filehippo/) && (m/^http:\/\/(.*?)\.(.*?)\/(.*?)\/(.*)\.([a-z0-9]{3,4})(\?.*)?/)) { |
118 | $y[0] =~ s/[a-z0-9]{2,5}/cdn./; |
119 | print $x . "http://" . $y[0] . $y[1] . "/" . $y[2] . "." . $y[3] . "\n"; |
122 | }
elsif (($u =~ /rapidshare/) &&
(m/^http:\/\/(([A-Za-z]+[0-9-.]+)*?)([a-z]*\.[^\/]{3}\/[a-z]*\/[0-9]*)\/(.*?)\/([^\/\?\&]{4,})$/))
{ |
123 | print $x . "http://cdn." . $3 . "/SQUIDINTERNAL/" . $5 . "\n"; |
125 | } elsif (($u =~ /maxporn/) && (m/^http:\/\/([^\/]*?)\/(.*?)\/([^\/]*?)(\?.*)?$/)) { |
126 | print $x . "http://" . $1 . "/SQUIDINTERNAL/" . $3 . "\n"; |
128 | #like porn hub variables url and center part of the path, filename etention 3 or 4 with or without ? at the end |
129 | }
elsif (($u =~ /tube8|pornhub|xvideos/) &&
(m/^http:\/\/(([A-Za-z]+[0-9-.]+)*?(\.[a-z]*)?)\.([a-z]*[0-9]?\.[^\/]{3}\/[a-z]*)(.*?)((\/[a-z]*)?(\/[^\/]*){4}\.[^\/\?]{3,4})(\?.*)?$/))
{ |
131 | #...spicific servers end here. |
133 | #photos-X.ak.fbcdn.net where X a-z |
134 | } elsif (m/^http:\/\/photos-[a-z].ak.fbcdn.net\/(.*)/) { |
138 | } elsif (m/^http:\/\/(.*yimg.com)\/\/(.*)\/([^\/\?\&]*\/[^\/\?\&]*\.[^\/\?\&]{3,4})(\?.*)?$/) { |
142 | } elsif (m/^http:\/\/(.*?)\.yimg\.com\/(.*?)\.yimg\.com\/(.*?)\?(.*)/) { |
145 | #for yimg.com with &sig= |
146 | } elsif (m/^http:\/\/(.*?)\.yimg\.com\/(.*)/) { |
148 | $y[0] =~ s/[a-z]+[0-9]+/cdn/; |
150 | print $x . "http://" . $y[0] . ".yimg.com/" . $y[1] . "\n"; |
152 | #youjizz. We use only domain and filename |
153 | }
elsif (($u =~ /media[0-9]{2,5}\.youjizz/) &&
(m/^http:\/\/(.*)(\.[^\.\-]*?\..*?)\/(.*)\/([^\/\?\&]*)\.([^\/\?\&]{3,4})((\?|\%).*)?$/))
{ |
155 | $y[0] =~ s/(([a-zA-A]+[0-9]+(-[a-zA-Z])?$)|(.*cdn.*)|(.*cache.*))/cdn/; |
156 | print $x . "http://" . $y[0] . $y[1] . "/" . $y[2] . "." . $y[3] . "\n"; |
158 | #general purpose for cdn servers. add above your specific servers. |
159 | } elsif (m/^http:\/\/([0-9.]*?)\/\/(.*?)\.(.*)\?(.*?)/) { |
163 | } elsif (m/^http:\/\/(.*)(\.[^\.\-]*?\..*?)\/(.*)\.([^\/\?\&]{2,4})((\?|\%).*)?$/) { |
165 | $y[0] =~ s/(([a-zA-A]+[0-9]+(-[a-zA-Z])?$)|(.*cdn.*)|(.*cache.*))/cdn/; |
166 | print $x . "http://" . $y[0] . $y[1] . "/" . $y[2] . "." . $y[3] . "\n"; |
169 | } elsif (m/^http:\/\/(([A-Za-z]+[0-9-]+)*?|.*cdn.*|.*cache.*)\.(.*?)\.(.*?)\/(.*)$/) { |
170 | print $x . "http://cdn." . $3 . "." . $4 . "/" . $5 . "\n"; |
172 | # spicific extention that ends with ? |
173 | } elsif (m/^http:\/\/(.*?)\/(.*?)\.(jp(e?g|e|2)|gif|png|tiff?|bmp|ico|flv|on2)(.*)/) { |
174 | print $x . "http://" . $1 . "/" . $2 . "." . $3 . "\n"; |
176 | # all that ends with ; |
177 | } elsif (m/^http:\/\/(.*?)\/(.*?)\;(.*)/) { |
178 | print $x . "http://" . $1 . "/" . $2 . "\n"; |
181 | print $x . $_ . "sucks\n"; |
Now start
SQUIDServer by
1 | /usr/local/squid/sbin/squid |
TIP:
To start
SQUID Server in
Debug mode, to check any erros, use
1 | /usr/local/squid/sbin/squid -d1 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |