]> git.openstreetmap.org Git - chef.git/blob - cookbooks/squid/templates/default/squid.conf.erb
bc6b1aff05642245c4c5de44e3cfa48546199b1c
[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 # FIXME - configurable
35 <% if node[:squid][:version] < 3 -%>
36 http_port 80 accel defaultsite=tile.openstreetmap.org tcpkeepalive=60,10,6 http11
37 <% else -%>
38 http_port 80 accel no-vhost defaultsite=tile.openstreetmap.org tcpkeepalive=60,10,6
39 <% end -%>
40
41 cache_effective_user proxy
42 cache_effective_group proxy
43
44 <% Array(node[:squid][:cache_dir]).each do |cache_dir| -%>
45 cache_dir <%= cache_dir %>
46 <% end -%>
47
48 <% if node[:squid][:version] < 3 -%>
49 cache_swap_log /var/spool/squid/%s
50 <% end -%>
51
52 cache_mgr webmaster@openstreetmap.org
53
54 quick_abort_min 0 KB
55 quick_abort_max 0 KB
56
57 read_ahead_gap 64 KB
58
59 maximum_object_size 256 KB
60 maximum_object_size_in_memory 64 KB
61
62 cache_replacement_policy heap LFUDA
63 memory_replacement_policy heap GDSF
64
65 server_persistent_connections on
66 <% if node[:squid][:version] < 3 -%>
67 persistent_request_timeout 1 minutes
68 <% else -%>
69 client_idle_pconn_timeout 1 minutes
70 <% end -%>
71 <% if node[:squid][:version] > 3 -%>
72 pconn_lifetime 5 minutes
73 <% end -%>
74
75 negative_ttl 15 seconds
76 <% if node[:squid][:version] < 3 -%>
77 pipeline_prefetch on
78 <% end -%>
79
80 read_timeout 90 seconds
81 request_timeout 90 seconds
82 connect_timeout 20 seconds
83 client_lifetime 1 hours
84
85 <% if node[:squid][:version] < 3 -%>
86 refresh_stale_hit 300 seconds
87 <% end -%>
88
89 # Recommended minimum configuration:
90 # ----------------------------------
91 <% if node[:squid][:version] < 3 -%>
92 acl all src all
93 acl manager proto cache_object
94 acl localhost src 127.0.0.1/32
95 acl to_localhost dst 127.0.0.0/8
96 <% end -%>
97 acl SSL_ports port 443
98 acl Safe_ports port 80          # http
99 acl Safe_ports port 21          # ftp
100 acl Safe_ports port 443         # https
101 acl Safe_ports port 70          # gopher
102 acl Safe_ports port 210         # wais
103 acl Safe_ports port 1025-65535  # unregistered ports
104 acl Safe_ports port 280         # http-mgmt
105 acl Safe_ports port 488         # gss-http
106 acl Safe_ports port 591         # filemaker
107 acl Safe_ports port 777         # multiling http
108 acl CONNECT method CONNECT
109 http_access allow manager localhost
110
111 http_access allow manager
112
113 http_access deny manager
114 http_access deny !Safe_ports
115 http_access deny CONNECT !SSL_ports
116 # ----------------------------------
117
118 acl purge_hosts src 127.0.0.0/8
119 acl PURGE method purge
120 http_access allow purge purge_hosts
121 http_access deny purge
122
123 forwarded_for on
124 follow_x_forwarded_for allow localhost
125
126 <% if node[:squid][:version] < 3 -%>
127 logformat openstreetmap %ts.%03tu %tr %>a %Ss/%03Hs %<st %rm %rp %Sh/%<A %mt "%{Referer}>h" "%{User-Agent}>h"
128 access_log <%= node[:squid][:access_log] %>
129 <% else -%>
130 logformat openstreetmap %ts.%03tu %tr %>a %Ss/%03>Hs %<st %rm %>rp %Sh/%<A %mt "%{Referer}>h" "%{User-Agent}>h"
131 access_log daemon:<%= node[:squid][:access_log] %>
132 <% end -%>
133 cache_log /var/log/squid/cache.log
134 cache_store_log none
135 buffered_logs on
136 client_db off
137 strip_query_terms off
138 <% if node[:squid][:version] > 2 -%>
139 # Work around bug in squid 3 that causes log_fqdn to be
140 # turned on by some of the (unused by us) default formats:
141 # http://lists.squid-cache.org/pipermail/squid-users/2016-February/thread.html#8999
142 url_rewrite_extras "%>a %un %>rm myip=%la myport=%lp"
143 store_id_extras "%>a %un %>rm myip=%la myport=%lp"
144 <% end -%>
145
146 digest_generation on
147
148 refresh_pattern .               0       50%     8640
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 # --------------