如何配置Squid来缓存所有下载的文件?

时间:2017-06-13 19:45:04

标签: caching proxy squid

我正在尝试设置一个Squid代理实例,以便它可以用于使用Test Kitchen进行Chef cookbook开发。

当Test Kitchen旋转虚拟机时,它会通过下载来安装chef-client。我已将其配置为通过代理服务器下载,但Squid不会缓存下载的文件,例如

enter image description here

认为这可能是因为它通过SSL访问但我不是100%肯定。这是因为Ubuntu VM中的apt配置为使用相同的代理实例,并且我在缓存中点击这些文件:

enter image description here

这是我的squid.conf文件:

http_port 3128

acl manager url_regex -i ^cache_object:// +i ^https?://[^/]+/squid-internal-mgr/

acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

acl localnet src 10.0.0.0/8     # RFC 1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC 1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC 1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access deny all

maximum_object_size 1024 MB
cache_replacement_policy heap LFUDA
cache_dir aufs /var/spool/squid3 5000 24 256
coredump_dir /var/spool/squid3

refresh_pattern ^ftp:          1440    20%     10080
refresh_pattern ^gopher:       1440    0%      1440
refresh_pattern Packages\.bz2$ 0       20%     4320 refresh-ims
refresh_pattern Sources\.bz2$  0       20%     4320 refresh-ims
refresh_pattern Release\.gpg$  0       20%     4320 refresh-ims
refresh_pattern Release$       0       20%     4320 refresh-ims
refresh_pattern -i .(deb|rpm|exe|zip|tar|tgz|bz2|ram|rar|bin)$  129600 100% 129600 override-expire ignore-no-cache ignore-no-store
refresh_pattern .              0       20%     4320

有人知道我需要添加到配置中的内容,以便它会缓存chef-client的下载吗?它是一个SSL链接吗?

1 个答案:

答案 0 :(得分:0)

就像这些事情的情况一样,我已经知道它确实与SSL有关。

原因是SSL意味着提供隐私的期望,因此默认情况下Squid不会缓存受保护的页面,因为它无法看到它们。

由于我只是将其用于包的缓存,我有两个选择:

  1. 使用普通的http url
  2. 下载chef-client
  3. 为Squid创建一个自签名证书,使其成为中间人,这样它就可以解密传入的数据并对其进行缓存。
  4. 目前1号更容易,而长期来看2号可能更强劲。

相关问题