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