]> git.openstreetmap.org Git - chef.git/blob - cookbooks/squid/templates/default/squid.conf.erb
22b94ddec829140a56e08dbe4684b13ac2d53544
[chef.git] / cookbooks / squid / templates / default / squid.conf.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 # configure host name
4 visible_hostname <%= node.name %>
5
6 cache_mem  <%= node[:squid][:cache_mem] %>
7 <% if node[:squid][:version] > 2 -%>
8
9 workers <%= [ node[:cpu][:total] - 2, 1 ].max.ceil %>
10 cpu_affinity_map process_numbers=<%= (1..[ node[:cpu][:total] - 2, 1 ].max.ceil).to_a.join(',') %> cores=<%=(1..[ node[:cpu][:total] - 2, 1 ].max.ceil).to_a.join(',') %>
11
12 error_log_languages off
13 <% end -%>
14
15 max_filedescriptors 98304
16
17 <% if node[:squid][:version] > 3 -%>
18 # Use RFC6891 recommended max size
19 dns_packet_max 4096 bytes
20 # Use low initial retry interval (backoff start)
21 dns_retransmit_interval 2 seconds
22 # Set low timeout
23 dns_timeout 15 seconds
24 <% end -%>
25
26 # used by squidclient / munin
27 http_port 3128
28 # HTCP
29 htcp_port 4827
30 # ICP
31 icp_port 3130
32 log_icp_queries off
33
34 <% if node[:squid][:version] < 3 -%>
35 http_port 80 accel defaultsite=tile.openstreetmap.org tcpkeepalive=60,10,6 http11
36 <% else -%>
37 http_port 80 accel no-vhost defaultsite=tile.openstreetmap.org tcpkeepalive=60,10,6
38 <% end -%>
39
40 cache_effective_user proxy
41 cache_effective_group proxy
42
43 <% Array(node[:squid][:cache_dir]).each do |cache_dir| -%>
44 cache_dir <%= cache_dir %>
45 <% end -%>
46
47 <% if node[:squid][:version] < 3 -%>
48 cache_swap_log /var/spool/squid/%s
49 <% end -%>
50
51 cache_mgr webmaster@openstreetmap.org
52
53 quick_abort_min 0 KB
54 quick_abort_max 0 KB
55
56 read_ahead_gap 64 KB
57
58 maximum_object_size 256 KB
59 maximum_object_size_in_memory 64 KB
60
61 cache_replacement_policy heap LFUDA
62 memory_replacement_policy heap GDSF
63
64 server_persistent_connections on
65 <% if node[:squid][:version] < 3 -%>
66 persistent_request_timeout 1 minutes
67 <% else -%>
68 client_idle_pconn_timeout 1 minutes
69 <% end -%>
70 <% if node[:squid][:version] > 3 -%>
71 pconn_lifetime 5 minutes
72 <% end -%>
73
74 negative_ttl 15 seconds
75 <% if node[:squid][:version] < 3 -%>
76 pipeline_prefetch on
77 <% end -%>
78
79 read_timeout 90 seconds
80 request_timeout 90 seconds
81 connect_timeout 20 seconds
82 client_lifetime 1 hours
83
84 <% if node[:squid][:version] < 3 -%>
85 refresh_stale_hit 300 seconds
86 <% end -%>
87
88 # Recommended minimum configuration:
89 # ----------------------------------
90 <% if node[:squid][:version] < 3 -%>
91 acl all src all
92 acl manager proto cache_object
93 acl localhost src 127.0.0.1/32
94 acl to_localhost dst 127.0.0.0/8
95 <% end -%>
96 acl SSL_ports port 443
97 acl Safe_ports port 80          # http
98 acl Safe_ports port 21          # ftp
99 acl Safe_ports port 443         # https
100 acl Safe_ports port 70          # gopher
101 acl Safe_ports port 210         # wais
102 acl Safe_ports port 1025-65535  # unregistered ports
103 acl Safe_ports port 280         # http-mgmt
104 acl Safe_ports port 488         # gss-http
105 acl Safe_ports port 591         # filemaker
106 acl Safe_ports port 777         # multiling http
107 acl CONNECT method CONNECT
108 http_access allow manager localhost
109
110 http_access allow manager
111
112 http_access deny manager
113 http_access deny !Safe_ports
114 http_access deny CONNECT !SSL_ports
115 # ----------------------------------
116
117 acl purge_hosts src 127.0.0.0/8
118 acl PURGE method purge
119 http_access allow purge purge_hosts
120 http_access deny purge
121
122 forwarded_for on
123 follow_x_forwarded_for allow localhost
124
125 <% if node[:squid][:version] < 3 -%>
126 logformat openstreetmap %ts.%03tu %tr %>a %Ss/%03Hs %<st %rm %rp %Sh/%<A %mt "%{Referer}>h" "%{User-Agent}>h"
127 access_log <%= node[:squid][:access_log] %>
128 <% else -%>
129 logformat openstreetmap %ts.%03tu %tr %>a %Ss/%03>Hs %<st %rm %>rp %Sh/%<A %mt "%{Referer}>h" "%{User-Agent}>h"
130 access_log daemon:<%= node[:squid][:access_log] %>
131 <% end -%>
132 cache_log /var/log/squid/cache.log
133 cache_store_log none
134
135 client_db off
136 strip_query_terms off
137 <% if node[:squid][:version] > 2 -%>
138 # Work around bug in squid 3 that causes log_fqdn to be
139 # turned on by some of the (unused by us) default formats:
140 # http://lists.squid-cache.org/pipermail/squid-users/2016-February/thread.html#8999
141 url_rewrite_extras "%>a %un %>rm myip=%la myport=%lp"
142 store_id_extras "%>a %un %>rm myip=%la myport=%lp"
143 <% end -%>
144
145 digest_generation on
146
147 refresh_pattern .               0       50%     20160
148 refresh_pattern -i tile.openstreetmap.org 60 80% 20160 reload-into-ims
149
150 # ZERO required for logrotate to work properly
151 logfile_rotate 0
152
153 <% Dir.glob("/etc/squid/squid.conf.d/*.conf") do |file| -%>
154 <%= File.read(file) %>
155 <% end -%>
156
157 # MUST BE LAST ACL
158 # --------------
159 http_access deny all
160 htcp_access deny all
161 icp_access deny all
162 # --------------