2

Squid on 18.04 server won't cache anything and the majority is tcp_tunnel/200 when I tail the access log and the cache log shows that nothing is cached. How can I get it to cache websites?

Squid Config:

http_port 3128  
refresh_pattern ftp: 1440 20% 10080  
refresh_pattern ^gopher: 1440 0% 1440  
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0  
refresh_pattern . 0 20% 4320  
acl localnet src 192.168.0.0/24  
acl localhost src 127.0.0.1  
acl SSL_ports port 443  
acl Safe_ports port 80  
acl Safe_ports port 21  
acl Safe_ports port 443  
acl Safe_ports port 70  
acl Safe_ports port 210  
acl Safe_ports port 1025-65535  
acl Safe_ports port 280  
acl Safe_ports port 488  
acl Safe_ports port 591  
acl Safe_ports port 777  
acl CONNECT method CONNECT  
acl url dstdomain "/etc/squid/url"  
acl key url_regex -i "/etc/squid/key"  
http_access allow localhost  
http_access deny !Safe_ports  
http_access deny CONNECT !SSL_ports  
http_access allow localnet  
http_access deny url  
http_access deny key  
cache_mem 1024 MB  
maximum_object_size_in_memory 100 MB  
cache_replacement_policy heap GDSF  
cache_dir ufs /etc/squid/cache 5120 16 256  
maximum_object_size 100 MB  
cache_swap_low 85  
cache_swap_high 90  
access_log /var/log/squid/access.log  
half_closed_clients off  
hosts_file /etc/hosts  
memory_pools off  
client_db off  
coredump_dir /var/spool/squid  
5
  • 1
    It may be helpful to post relevant parts of the squid configuration you have already. Maybe try this: sed 's/#.*//;s/^\s*$//;/^$/d' /etc/squid/squid.conf to make the output easier to parse.
    – isaaclw
    Jan 8, 2019 at 17:16
  • @isaaclw I've added the config to the question
    – Manzy
    Jan 8, 2019 at 22:27
  • 1
    I assume you intend to have squid cache in /etc/squid/cache. Usually /var/cache/ or /var/spool/ is the recommended cache directory. Regardless, could you check to see if the approprate file structure is there? Even if it is, you may need to run some kind of 'squid cache initialization' Regardless, you probably want to turn on # cache_log /var/log/squid/cache.log and tail it while you restart. The logging is a bit counter-intuitive, since the 'cache' log is where squid errors go, and 'access' log is the "usual operations" log, ie: where requests go in and out.
    – isaaclw
    Jan 15, 2019 at 17:06
  • After you tail /var/log/squid/cache.log if you see any errors that you don't understand you can add them to this post.
    – isaaclw
    Jan 15, 2019 at 17:07
  • Nowadays, with most websites being HTTPS, there is little use for caching proxy.
    – raj
    Sep 4, 2023 at 19:59

1 Answer 1

1

Squid does not cache anything if TCP_TUNNEL is used for 443. It just relays packets back and forth from client <-> server without knowing what is in them as they are SSL encrypted.

To have squid cache https sites, one has to have squid able to be a "MITM" in the SSL connection. That is, it has to issue certificates on the fly to "pretend" to be the destination.

Read here if you really want this (it involves setting up your own certificate authority and all clients have to trust it).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .