Advertisement
Guest User

squid-external.conf.mas

a guest
Oct 25th, 2013
955
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.66 KB | None | 0 0
  1. <%doc>
  2. Main configuration file for Squid daemon
  3.  
  4. Parameters:
  5.  
  6. snmpEnabled - Boolean indicating if SNMP is enabled or not
  7. </%doc>
  8. <%args>
  9. $port
  10. $transparent => undef
  11.  
  12. $hostfqdn
  13. $realm => ''
  14.  
  15. $memory
  16. $cacheDirSize
  17. $max_object_size
  18.  
  19. @nameservers
  20. $append_domain
  21.  
  22. $cache_host
  23. $cache_port
  24. $cache_user
  25. $cache_passwd
  26.  
  27. $urlRewriteProgram => undef
  28. @objectsDelayPools
  29. @notCachedDomains
  30.  
  31. $snmpEnabled => 0
  32. </%args>
  33. <%shared>
  34. our $anyPrefix = 'any_src_';
  35. our $maxAclNameLength = 31;
  36. our %longAclNames = ();
  37. </%shared>
  38. <%perl>
  39. # needed because space scape doesnt work in acl names
  40. sub _escapeWS
  41. {
  42. my ($string) = @_;
  43. $string =~ s{ }{__}g;
  44. return $string;
  45. }
  46. # needed to avoid log acl problems
  47. sub _aclName
  48. {
  49. my ($name) = @_;
  50. if (length($name) <= $maxAclNameLength) {
  51. return _escapeWS($name);
  52. }
  53.  
  54. if (not exists $longAclNames{$name}) {
  55. my $nextId = 1 + keys %longAclNames;
  56. $nextId = 'longAcl' . $nextId;
  57. $longAclNames{$name} = $nextId;
  58. }
  59.  
  60. return _escapeWS($longAclNames{$name});
  61. }
  62. </%perl>
  63. <%def .rulesACLs>
  64. <%args>
  65. @rules
  66. $realm
  67. </%args>
  68. % foreach my $rule (@rules) {
  69. % if ($rule->{any}) {
  70. <& .timeACLs, rule => $rule, id => $anyPrefix . $rule->{number} &>
  71. % next;
  72. % }
  73. % my $object = $rule->{object};
  74. % my $group = $rule->{group};
  75. % my $src = $object ? $object : $group;
  76. % my $aclName = _aclName($src);
  77. % if ($object) {
  78. acl <% $aclName %> src <% join ' ', @{ $rule->{addresses} } %>
  79. % } else {
  80. % # escape user names
  81. % my @users = map { $_ =~ s{ }{\\ }g; $_ } @{$rule->{users}};
  82. % if ($realm) {
  83. % @users = map { $_ . '@' . $realm } @users;
  84. % }
  85. acl <% $aclName %> proxy_auth <% join (' ', @users) %>
  86. % }
  87. <& .timeACLs, rule => $rule, id => $src &>
  88. % }
  89. </%def>
  90.  
  91. <%def .timeACLs>
  92. <%args>
  93. $rule
  94. $id
  95. </%args>
  96. % if ($rule->{timeDays}) {
  97. acl <% _aclName('timeDays_' . $id) %> time <% $rule->{timeDays} %>
  98. % }
  99. % if ($rule->{timeHours}) {
  100. acl <% _aclName('timeHours_' . $id) %> time <% $rule->{timeHours} %>
  101. % }
  102. </%def>
  103.  
  104. <%def .delayPools>
  105. <%args>
  106. @objectsDelayPools
  107. </%args>
  108. % if ( @objectsDelayPools ) {
  109. % my $pools = @objectsDelayPools;
  110. delay_pool_uses_indirect_client on
  111. delay_pools <% $pools %>
  112. % }
  113. <%perl>
  114. my $id = 0;
  115. foreach my $objPool (@objectsDelayPools) {
  116. $id++;
  117. my $rate = $objPool->{rate};
  118. if ($rate > 0) {
  119. $rate *= 1024;
  120. }
  121. my $size = $objPool->{size};
  122. if ($size > 0) {
  123. $size *= 1024 * 1024;
  124. }
  125. </%perl>
  126. delay_class <% $id %> <% $objPool->{class} %>
  127. % if ( $objPool->{class} eq '1' ) {
  128. delay_parameters <% $id %> <% $rate %>/<% $size %>
  129. % } elsif ( $objPool->{class} eq '2' ) {
  130. <%perl>
  131. my $clt_rate = $objPool->{clt_rate};
  132. if ($clt_rate > 0) {
  133. $clt_rate *= 1024;
  134. }
  135. my $clt_size = $objPool->{clt_size};
  136. if ($clt_size > 0) {
  137. $clt_size *= 1024 * 1024;
  138. }
  139. </%perl>
  140. delay_parameters <% $id %> <% $rate %>/<% $size %> <% $clt_rate %>/<% $clt_size %>
  141. % }
  142. delay_initial_bucket_level 90
  143. delay_access <% $id %> allow <% $objPool->{object} %>
  144. delay_access <% $id %> deny all
  145. % }
  146. </%def>
  147.  
  148. <%def .snmp>
  149. <%doc>
  150. Define the SNMP configuration as SNMP agent
  151. </%doc>
  152. acl snmppublic snmp_community public
  153. snmp_port 3401
  154. snmp_access allow snmppublic from_localhost
  155. snmp_access deny all
  156. </%def>
  157. ###################################################################################
  158. http_port localhost:<% $port %> ignore-cc
  159.  
  160.  
  161. visible_hostname (external)<% $hostfqdn %>
  162.  
  163. coredump_dir /var/spool/squid3
  164. cache_effective_user proxy
  165. cache_effective_group proxy
  166. cache_mem 512 MB
  167. cache_dir aufs /var/spool/squid3 <% $cacheDirSize %> 16 256
  168. maximum_object_size 800 MB
  169. maximum_object_size_in_memory 1024 KB
  170. memory_pools off
  171. ipcache_size 10240
  172. buffered_logs on
  173. range_offset_limit 0
  174. client_db off
  175. forwarded_for off
  176. via off
  177. half_closed_clients off
  178. pipeline_prefetch on
  179. quick_abort_min 1 MB
  180. range_offset_limit 10 MB
  181. access_log /var/log/squid3/external-access.log squid
  182. cache_log /var/log/squid3/external-cache.log
  183. cache_store_log /var/log/squid3/external-store.log
  184. pid_filename /var/run/squid3-external.pid
  185. % if (@nameservers) {
  186. % my $dns_nameservers = '';
  187. % foreach my $srv (@nameservers) {
  188. % $dns_nameservers .= "$srv ";
  189. % }
  190. dns_nameservers <% $dns_nameservers %>
  191. % }
  192. % if ($append_domain) {
  193. append_domain .<% $append_domain %>
  194. % }
  195.  
  196. # refresh patterns
  197.  
  198. # windows updates
  199. refresh_pattern http://.*\.windowsupdate\.microsoft\.com/ 0 80% 20160 reload-into-ims
  200. refresh_pattern http://.*\.update\.microsoft\.com/ 0 80% 20160 reload-into-ims
  201. refresh_pattern http://download\.microsoft\.com/ 0 80% 20160 reload-into-ims
  202. refresh_pattern http://windowsupdate\.microsoft\.com/ 0 80% 20160 reload-into-ims
  203. refresh_pattern http://.*\.download\.windowsupdate\.com/ 0 80% 20160 reload-into-ims
  204. refresh_pattern http://office\.microsoft\.com/ 0 80% 20160 reload-into-ims
  205. refresh_pattern http://w?xpsp[0-9]\.microsoft\.com/ 0 80% 20160 reload-into-ims
  206. refresh_pattern http://w2ksp[0-9]\.microsoft\.com/ 0 80% 20160 reload-into-ims
  207.  
  208. # linux updates
  209. refresh_pattern http://.*\.archive\.ubuntu\.com/ 0 80% 20160 reload-into-ims
  210. refresh_pattern http://(ftp|http)[0-9]*\.[a-z]+\.debian\.org/ 0 80% 20160 reload-into-ims
  211.  
  212. refresh_pattern ^ftp: 1440 20% 10080
  213. refresh_pattern ^gopher: 1440 0% 1440
  214. refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
  215. refresh_pattern . 0 20% 4320
  216.  
  217. # end refresh patterns
  218.  
  219. % if ($cache_host and $cache_port) {
  220. % my $peerAuth = '';
  221. % if ($cache_user and $cache_passwd) {
  222. # WARN: remember that for squid auth % are HTML escapes
  223. % $peerAuth = 'login=' . $cache_user . ':' . $cache_passwd;
  224. % }
  225. cache_peer <% $cache_host %> parent <% $cache_port %> 0 no-query no-digest <% $peerAuth %>
  226. % }
  227.  
  228. % if ($urlRewriteProgram) {
  229. url_rewrite_program <% $urlRewriteProgram %>
  230. % }
  231.  
  232. <& .rulesACLs, rules => [ @objectsDelayPools ], realm => $realm &>
  233. acl_uses_indirect_client on
  234.  
  235. # no cache domains acl
  236. % foreach my $domain (@notCachedDomains) {
  237. acl noCached dstdomain <% $domain %>
  238. % }
  239.  
  240.  
  241. acl from_localhost src 127.0.0.0/8 ::1
  242. acl to_localhost dst 127.0.0.0/8 ::1
  243. acl manager url_regex -i ^cache_object:// +i ^https?://[^/]+/squid-internal-mgr/
  244. acl SSL_ports port 443 # https, snews
  245. acl SSL_ports port 873 # rsync
  246. acl Safe_ports port 80 # http
  247. acl Safe_ports port 21 # ftp
  248. acl Safe_ports port 443 563 # https, snews
  249. acl Safe_ports port 70 # gopher
  250. acl Safe_ports port 210 # wais
  251. acl Safe_ports port 1025-65535 # unregistered ports
  252. acl Safe_ports port 280 # http-mgmt
  253. acl Safe_ports port 488 # gss-http
  254. acl Safe_ports port 591 # filemaker
  255. acl Safe_ports port 631 # cups
  256. acl Safe_ports port 777 # multiling http
  257. acl Safe_ports port 873 # rsync
  258. acl Safe_ports port 901 # SWAT
  259.  
  260. acl CONNECT method CONNECT
  261. acl purge method PURGE
  262.  
  263.  
  264. follow_x_forwarded_for allow from_localhost
  265. log_uses_indirect_client on
  266.  
  267. http_access allow manager to_localhost
  268.  
  269. http_access deny manager
  270. http_access deny purge
  271. http_access deny !Safe_ports
  272.  
  273. http_access deny CONNECT !SSL_ports
  274. http_access allow from_localhost
  275.  
  276. # we use firewall to deny clients from the outside
  277. http_access allow all
  278. % if ($cache_host and $cache_port) {
  279. never_direct allow all
  280. % }
  281.  
  282. <& .delayPools, objectsDelayPools => \@objectsDelayPools &>
  283.  
  284. % if ( $snmpEnabled ) {
  285. <& .snmp &>
  286. % }
  287.  
  288. always_direct allow to_localhost
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement