Advertisement
punces

squid.conf+storeid.pl+speedtest.pl

Sep 26th, 2016
1,434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.44 KB | None | 0 0
  1. ########################################################## SQUID.CONF ##################################################################
  2. dns_v4_first on
  3. reply_header_access Alternate-Protocol deny all
  4. reply_header_access Alt-Svc deny all
  5.  
  6. #cache_dir aufs /cache 700000 16 256
  7. cache_dir aufs /cache 360000 1 1
  8. cache_mem 8 MB
  9. coredump_dir /var/log/squid
  10.  
  11. cache_swap_low 80
  12. cache_swap_high 85
  13. cache_replacement_policy heap LFUDA
  14. memory_replacement_policy heap GDSF
  15.  
  16. maximum_object_size 4096000 KB
  17. maximum_object_size_in_memory 0 KB
  18. request_body_max_size 0 KB
  19. refresh_all_ims on
  20. reload_into_ims on
  21.  
  22. visible_hostname cespun-proxy
  23. strip_query_terms off
  24. httpd_suppress_version_string on
  25. log_mime_hdrs off
  26. forwarded_for off
  27. via off
  28.  
  29. request_header_access X-Forwarded-For deny all
  30. reply_header_access X-Forwarded-For deny all
  31. request_header_access Via deny all
  32. reply_header_access Via deny all
  33. max_filedescriptors 65536
  34.  
  35. cache_swap_high 98
  36. cache_swap_low 95
  37. fqdncache_size 4096
  38. ipcache_size 4096
  39. dns_nameservers 208.67.222.222 208.67.220.220
  40.  
  41. http_port 3128
  42. #http_port 3127 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/warnet.pem
  43. #http_port 3129 intercept
  44. #https_port 3127 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/warnet.pem
  45. http_port 3129 tproxy
  46. https_port 3127 tproxy ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/warnet.pem
  47.  
  48. qos_flows local-hit=0x30
  49.  
  50. acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
  51. acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
  52. acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
  53. acl localnet src fc00::/7 # RFC 4193 local private network range
  54. acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
  55. acl SSL_ports port 443
  56. acl Safe_ports port 80 # http
  57. acl Safe_ports port 182 # http
  58. acl Safe_ports port 21 # ftp
  59. acl Safe_ports port 443 # https
  60. acl Safe_ports port 70 # gopher
  61. acl Safe_ports port 210 # wais
  62. acl Safe_ports port 1025-65535 # unregistered ports
  63. acl Safe_ports port 280 # http-mgmt
  64. acl Safe_ports port 488 # gss-http
  65. acl Safe_ports port 591 # filemaker
  66. acl Safe_ports port 777 # multiling http
  67.  
  68. acl step1 at_step SslBump1
  69. acl step2 at_step SslBump2
  70. acl step3 at_step SslBump3
  71. #acl sslserver ssl::server_name_regex -i "/etc/squid/bypass.txt"
  72. #acl iphone browser -i regexp (iPhone|iPad)
  73. #acl BB browser -i regexp (BlackBerry|PlayBook)
  74. #acl Winphone browser -i regexp (Windows.*Phone|Trident|IEMobile)
  75. #acl Android browser -i regexp Android
  76. acl yt-modif url_regex -i ^https?\:\/\/www\.youtube\.com\/(watch\?v|embed|v)
  77. acl youtube url_regex -i ^http.*(youtube|googlevideo|videoplayback|videogoodput)
  78. acl versipatch url_regex -i ^http.*(update|patch).*versi
  79. acl versipatch url_regex -i ^http.*versi.*(update|patch)
  80. acl versipatch url_regex -i ^http.*(antihack|xigncode|gameguard)
  81. #acl patchpartial url_regex -i ^http.*(garena|gemscool|netmarble|valve|dota|winnerinter|lytogame|megaxus).*patch
  82. #acl patchpartial url_regex -i ^http.*patch.*(garena|gemscool|netmarble|valve|dota|winnerinter|lytogame|megaxus)
  83. acl patchpartial url_regex -i ^http.*patch.*garena
  84. acl patchpartial url_regex -i ^http.*garena.*patch
  85. acl httptomiss http_status 302
  86. acl mimehtml rep_mime_type -i mime-type ^text/html
  87. acl mimeplain rep_mime_type -i mime-type ^text/plain
  88. acl tostoreid url_regex -i ^http.*(youtube|googlevideo|videoplayback|videogoodput)
  89. acl tostoreid url_regex -i ^http.*(fbcdn|akamaihd)
  90. acl tostoreid url_regex -i ^http.*c2lo\.reverbnation\.com\/audio_player\/ec_stream_song\/.*\?
  91. acl tostoreid url_regex -i ^http.*\.c\.android\.clients\.google\.com\/market\/GetBinary\/GetBinary\/.*\/.*\?
  92. acl tostoreid url_regex -i ^http.*datafilehost.*\/get\.php.*file\=.*
  93. acl tostoreid url_regex -i ^http.*\.filehippo\.com\/.*\?
  94. acl tostoreid url_regex -i ^http.*\.4shared\.com\/.*\/.*\/.*\/dlink.*preview.mp3
  95. acl tostoreid url_regex -i ^http.*\.4shared\.com\/download\/.*\/.*\?tsid
  96. acl tostoreid url_regex -i ^http.*steam(powered|content)
  97. acl tostoreid url_regex -i ^http.*savefile\.co\:182\/.*\/.*\.(mp4|flv|3gp)
  98. acl tostoreid url_regex -i ^http.*video\-http\.media\-imdb\.com\/.*\.mp4\?
  99. acl tostoreid url_regex -i ^http.*\.dl\.sourceforge\.net
  100. #acl tostoreid url_regex -i ^http.*(speedtest|espeed).*\/.*\.(jpg|txt)
  101. acl speedtest url_regex -i ^http.*(speedtest|espeed).*\/(latency|upload|random.*)\.(jpg|txt|php)
  102. acl CONNECT method CONNECT
  103. acl getmethod method GET
  104.  
  105. http_access deny !Safe_ports
  106. http_access deny CONNECT !SSL_ports
  107. http_access allow localhost manager
  108. http_access deny manager
  109. http_access allow localnet
  110. http_access allow localhost
  111. http_access deny all
  112.  
  113. request_header_access Range deny !patchpartial
  114. #range_offset_limit 128 KB !patchpartial
  115. range_offset_limit none patchpartial
  116. quick_abort_min 1 KB
  117. quick_abort_max 1 KB
  118. quick_abort_pct 95
  119.  
  120. #request_header_access User-Agent deny yt-modif !iphone !BB !Winphone !Android
  121. ### flash
  122. #request_header_replace User-Agent Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14
  123. ### flash
  124. #request_header_replace User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14
  125. ###html5
  126. #request_header_replace User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
  127. ###html5
  128. #request_header_replace user_Agent Mozilla/5.0 (Windows NT 5.1; rv:35.0) Gecko/20100101 Firefox/35.0
  129. #request_header_replace Mozilla/6.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:2.0.0.0) Gecko/20061028 Firefox/3.0
  130.  
  131. cache deny versipatch
  132. cache deny localhost
  133. ssl_bump splice localhost
  134. #ssl_bump splice sslserver
  135. ssl_bump peek step1 all
  136. ssl_bump bump step2 all
  137. ssl_bump splice step3 all
  138.  
  139.  
  140.  
  141. sslcrtd_program /usr/lib/squid/ssl_crtd -s /var/lib/ssl_db -M 4MB
  142. sslcrtd_children 2000 startup=30 idle=1
  143. sslproxy_capath /etc/squid/ssl_cert
  144. sslproxy_cert_error allow all
  145. sslproxy_flags DONT_VERIFY_PEER
  146. sslproxy_flags NO_SESSION_REUSE
  147. ssl_unclean_shutdown on
  148. #sslproxy_options NO_SSLv2,NO_SSLv3,SINGLE_ECDH_USE #Jika menggunakan versi setelah squid-3.5.12-20151222-r13967
  149. sslproxy_options NO_SSLv2,NO_SSLv3
  150. sslproxy_cipher EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:HIGH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS
  151.  
  152. #debug_options 11,2 22,3
  153. logfile_rotate 1
  154. #logformat referer %ts.%03tu %>a %{Referer}>h %ru
  155. #logformat referer %ts.%03tu %>a %ru %{Referer}>h
  156. #logformat referer %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt %{Referer}>h %{User-Agent}>h
  157. #access_log /var/log/squid/access.log !CONNECT
  158. #access_log /var/log/squid/connect.log CONNECT
  159. #cache_store_log /var/log/squid/store.log
  160. access_log stdio:/var/log/squid/access.log
  161. netdb_filename none
  162.  
  163.  
  164. #ecap
  165. #yt_quality: tiny = 144px small = 240px medium = 360px large = 480px HD720 = Hd720px
  166. loadable_modules /usr/local/lib/ecap_adapter_modifying.so
  167. ecap_enable on
  168. request_header_access Accept-Encoding deny yt-modif
  169. ecap_service modif respmod_precache uri=ecap://e-cap.org/ecap/services/sample/modifying victim="enablejsapi" replacement="dash":"0","vq":"medium","enablejsapi"
  170. #ecap_service modif respmod_precache uri=ecap://e-cap.org/ecap/services/sample/modifying victim="enablejsapi" replacement="dash":"1","vq":"tiny","enablejsapi"
  171. #ecap_service modif respmod_precache uri=ecap://e-cap.org/ecap/services/sample/modifying victim="enablejsapi" replacement="vq":"small","enablejsapi"
  172. adaptation_access modif allow yt-modif
  173. adaptation_access modif deny all
  174.  
  175. cache deny speedtest
  176. url_rewrite_access allow speedtest
  177. url_rewrite_access deny all
  178. url_rewrite_program /etc/squid/speedtest.pl
  179. redirector_bypass on
  180. cache_peer 10.212.212.212 parent 8033 0 no-digest no-tproxy
  181. dead_peer_timeout 5 seconds
  182. cache_peer_access 10.212.212.212 allow speedtest
  183. cache_peer_access 10.212.212.212 deny all
  184. always_direct deny speedtest
  185. never_direct allow speedtest
  186. url_rewrite_children 2000 startup=30 idle=1
  187.  
  188. store_id_bypass off
  189. store_id_extras "%{Referer}>h"
  190. store_id_program /etc/squid/storeid.pl
  191. store_id_children 2000 startup=30 idle=1
  192. store_id_access deny !getmethod
  193. store_id_access allow tostoreid
  194. store_id_access deny all
  195.  
  196. store_miss deny youtube httptomiss
  197. send_hit deny youtube httptomiss
  198. store_miss deny youtube mimeplain
  199. send_hit deny youtube mimeplain
  200. store_miss deny mimehtml
  201. send_hit deny mimehtml
  202. store_miss deny versipatch
  203. send_hit deny versipatch
  204.  
  205. refresh_pattern -i . 0 90% 432000 override-expire override-lastmod reload-into-ims refresh-ims ignore-no-store ignore-must-revalidate ignore-private ignore-auth store-stale
  206. max_stale 1 day
  207.  
  208.  
  209. ############################################################ STOREID.PL #########################################################
  210. #!/usr/bin/perl
  211. $| = 1;
  212.  
  213. while (<>) {
  214.  
  215. @X = split;
  216. if ($X[0] =~ m/^http.*/) {
  217. $url = $X[0];
  218. $referer = $X[1];
  219. $urlreferer = $X[0] ." ". $X[1];
  220. } else {
  221. $chanel = $X[0];
  222. $url = $X[1];
  223. $referer = $X[2];
  224. $urlreferer = $X[1] ." ". $X[2];
  225. }
  226.  
  227.  
  228.  
  229.  
  230. #youtube googlevideo
  231. if ($url =~ m/^https?\:\/\/.*google.*video(playback|goodput).*/){
  232. @cpn = m/[=%&?\/]cpn[=%&?\/]([^\&\s]*)/;
  233. @id = m/[=%&?\/]id[=%&?\/]([^\&\s]*)/;
  234. @itag = m/[=%&?\/]itag[=%&?\/]([\d]*)/;
  235. @range = m/[=%&?\/]range[=%&?\/]([\d]*-[\d]*)/;
  236. @mime = m/[=%&?\/]mime[=%&?\/]([^\&\s]*)/;
  237. if ($referer =~ m/^https?\:\/\/www\.youtube\.com\/(watch\?v|embed|v)[=%&?\/]([^\&\s\?]*)/){
  238. @id = $2;
  239. } else {
  240. if (defined(@cpn[0])){
  241. if (-e "/tmp/@cpn"){
  242. open FILE, "/tmp/@cpn";
  243. @id = <FILE>;
  244. close FILE;
  245. }
  246. }
  247. }
  248. $out="OK store-id=http://squid/google/video/id=@id/itag=@itag/mime=@mime/range=@range";
  249.  
  250. #youtube parameter
  251. } elsif (
  252. ($url =~ m/^https?\:\/\/.*youtube.*(stream_204|watchtime|qoe|atr|csi_204|playback).*[=%&?\/]docid[=%&?\/]([^\&\s]*)/) ||
  253. ($url =~ m/^https?\:\/\/.*youtube.*(ptracking|set_awesome).*[=%&?\/]video_id[=%&?\/]([^\&\s]*)/) ||
  254. ($url =~ m/^https?\:\/\/.*youtube.*(player_204).*[=%&?\/]v[=%&?\/]([^\&\s]*)/)
  255. ){
  256. @id = $2;
  257. @cpn = m/[=%&?\/]cpn[=%&?\/]([^\&\s]*)/;
  258. if ($referer !~ m/^https?\:\/\/www\.youtube\.com\/(watch\?v|embed|v)[=%&?\/]([^\&\s\?]*)/){
  259. unless (-e "/tmp/@cpn"){
  260. open FILE, ">/tmp/@cpn";
  261. print FILE @id;
  262. close FILE;
  263. }
  264. }
  265. $out = "ERR";
  266.  
  267. #utmgif
  268. } elsif ($url =~ m/^https?\:\/\/www\.google-analytics\.com\/__utm\.gif\?.*/) {
  269. $out="OK store-id=http://squid/google-analytics/__utm.gif";
  270.  
  271. #fbcdn.net or akamaihd.net video range
  272. } elsif ($url =~ m/^https?\:\/\/.*(fbcdn\.net|akamaihd\.net).*\/([\w-]+\.[\w]{2,4}).*(bytestart[=%&?\/][\d]+[&\/]byteend[=%&?\/][\d]+)/) {
  273. $out="OK store-id=http://squid/$1/$2/$3";
  274.  
  275. #fbcdn.net or akamaihd.net with size
  276. } elsif ($url =~ m/^https?\:\/\/.*(fbcdn\.net|akamaihd\.net).*\/([a-zA-Z][\d]+[x][\d]+\/[\w-]+\.[\w]{2,4})($|\?)/) {
  277. $out="OK store-id=http://squid/$1/$2";
  278.  
  279. #fbcdn.net or akamaihd.net safe_image.php
  280. } elsif ($url =~ m/^https?\:\/\/.*(fbcdn\.net|akamaihd\.net).*\/safe_image\.php\?(.*)/) {
  281. $out="OK store-id=http://squid/$1/$2";
  282.  
  283. #reverbnation
  284. } elsif ($url =~ m/^https?\:\/\/c2lo\.reverbnation\.com\/audio_player\/ec_stream_song\/(.*)\?.*/) {
  285. $out="OK store-id=http://squid/reverbnation/$1";
  286.  
  287. #playstore
  288. } elsif ($url =~ m/^https?\:\/\/.*\.c\.android\.clients\.google\.com\/market\/GetBinary\/GetBinary\/(.*\/.*)\?.*/) {
  289. $out="OK store-id=http://squid/android/market/$1";
  290.  
  291.  
  292. #filehost
  293. } elsif ($url =~ m/^https?\:\/\/.*datafilehost.*\/get\.php.*file\=(.*)/) {
  294. $out="OK store-id=http://squid/datafilehost/$1";
  295.  
  296.  
  297. #speedtest
  298. } elsif ($url =~ m/^https?\:\/\/.*(speedtest|espeed).*\/(.*\.(txt|jpg)).*/) {
  299. $out="OK store-id=http://squid/speedtest/$2";
  300.  
  301.  
  302. #filehippo
  303. } elsif ($url =~ m/^https?\:\/\/.*\.filehippo\.com\/.*\/([\w-]+\.[\w]{2,4})\?.*/) {
  304. $out="OK store-id=http://squid/filehippo/$1";
  305.  
  306.  
  307. #4shared preview.mp3
  308. } elsif ($url =~ m/^https?\:\/\/.*\.4shared\.com\/.*\/(.*\/.*)\/dlink.*preview.mp3/) {
  309. $out="OK store-id=http://squid/4shared/preview/$1";
  310.  
  311. #4shared
  312. } elsif ($url =~ m/^https?\:\/\/.*\.4shared\.com\/download\/(.*\/.*)\?tsid.*/) {
  313. $out="OK store-id=http://squid/4shared/download/$1";
  314.  
  315. #savefile-animeindo.tv
  316. } elsif ($url =~ m/^https?:\/\/www\.savefile\.co\:182\/.*\/(.*\.(mp4|flv|3gp)).*/) {
  317. $out="OK store-id=http://squid/savefile:182/$1";
  318.  
  319. #imdb
  320. } elsif ($url =~ m/^https?\:\/\/video\-http\.media\-imdb\.com\/(.*\.mp4)\?.*/) {
  321. $out="OK store-id=http://squid/imdb/$1";
  322.  
  323. #sourceforge
  324. } elsif ($url =~ m/^https?\:\/\/.*\.dl\.sourceforge\.net\/([\w-]+\.[\w]{2,3})/) {
  325. $out="OK store-id=http://squid/sourceforge/$1";
  326.  
  327. #steampowered dota 2
  328. } elsif ($url =~ m/^https?\:\/\/.*steam(powered|content).*\/((client|depot)\/[\d]+\/(chunk|manifest)\/[^\?\s]*).*/) {
  329. $out="OK store-id=http://squid/steam/content-powered/$2";
  330.  
  331. } else {
  332. $out="ERR";
  333. }
  334.  
  335. if ($X[0] =~ m/^http.*/) {
  336. print "$out\n";
  337. } else {
  338. print "$chanel $out\n";
  339. }
  340. }
  341.  
  342.  
  343.  
  344. #################### SPEEDTEST.PL ##########
  345. #!/usr/bin/perl
  346.  
  347. $|=1;
  348. while (<>) {
  349. @X = split;
  350. if ($X[0] =~ m/^http.*/) {
  351. $url = $X[0];
  352. $referer = $X[1];
  353. $urlreferer = $X[0] ." ". $X[1];
  354. } else {
  355. $chanel = $X[0];
  356. $url = $X[1];
  357. $referer = $X[2];
  358. $urlreferer = $X[1] ." ". $X[2];
  359. }
  360.  
  361. if ($url=~ m/^https?\:\/\/.*(speedtest|espeed).*\/((latency|upload|random.*)\.(jpg|txt|php))/) {
  362. $out="OK rewrite-url=http://10.212.212.212:8033/speedtest/$2";
  363. } else {
  364. $out="ERR";
  365. }
  366.  
  367. if ($X[0] =~ m/^http.*/) {
  368. print "$out\n";
  369. } else {
  370. print "$chanel $out\n";
  371. }
  372. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement