About Squid proxy servers

Squid is a proxy cache server which provides proxy and cache services for Hyper Text Transport Protocol (HTTP), File Transfer Protocol (FTP), and other popular network protocols.

It acts as an intermediary between web servers and clients. When a client sends a request for content, Squid fetches the content from the web server and creates a local copy. Then, if a request is made again, it shows the local, cached copy instead of making another request to the web server. In this way, performance is improved and network bandwidth is optimised. It can also filter web traffic, helping to improve security.

Features

The Squid proxy cache server scales from the branch office to enterprise level networks. It provides extensive, granular access controls, and monitoring of critical parameters via the Simple Network Management Protocol (SNMP).

When selecting a computer system for use as a dedicated Squid caching proxy server, it is helpful to configure it with a large amount of physical memory as Squid maintains an in-memory cache for increased performance.

Caching

Squid can implement caching and proxying of Secure Sockets Layer (SSL) requests and caching of Domain Name Server (DNS) lookups, and perform transparent caching. Squid also supports a wide variety of caching protocols, such as Internet Cache Protocol (ICP), the Hyper Text Caching Protocol (HTCP), the Cache Array Routing Protocol (CARP), and the Web Cache Coordination Protocol (WCCP).

If you would like to know how to install and configure your own Squid server, refer to our installation guide.

Further reading

This is missing a config to create an on-disk cache. The default setup from the package has only a memory cache, meaning, if squid is restarted, that cache is lost.

I just addressed your comment, added the cache_dir directive. Thanks for the heads-up Andreas.

Ahoyhoy,

On Ubuntu 18.04 squid is configured to start via /etc/init.d/squid

Unfortunately, Ubuntu 18.04 uses systemd, so it has to use systemd-sysv-generator to start squid , and when doing so, it becomes a challenge to change the startup dependencies. In my case, I configured squid to use a zfs mount point for its cache directory, but on startup, squid gets called to initialize before the mount point is ready, so it fails.

I do not have a solution to this. I would rather not hack the /etc/init.d/squid script provided in the Ubuntu package; does Ubuntu have a solution for 18.04 LTS?

I am kind-of cross-posting here, I also asked on stackexchange: https://stackoverflow.com/questions/62290028/how-to-properly-override-generated-systemd-unit-file-to-start-after-a-zfs-mount

The solution I settled on was to create a systemd override.conf file. A systemd unit definition that is automatically generated from systemd-sysv-generator does not respect Want= or After= tags in the override.conf, but it does respect ExecStartPre, where you can put a sleep time:

% cat /etc/systemd/system/squid.service.d/override.conf
[Unit]
Description=Squid Web Proxy Server
Documentation=man:squid(8)
# These aren't effective, but I kept them from my earlier attempts.
Wants=zfs-mount.target
After=network.target network-online.target nss-lookup.target media.mount zfs-mount.target

[Service]
ExecStartPre=/bin/sleep 20

[Install]
WantedBy=multi-user.target

Thank you @wmarler for providing this feedback regarding the article.

After some local tests, I believe that it is actually possible to establish a dependency relationship between a service file that was generated by systemd-sysv-generator and another regular systemd service. Here’s a quick example on how to do it:

mkdir /etc/systemd/system/squid.service.d
cat > /etc/systemd/system/squid.service.d/90-start-after-xyz.conf << _EOF_
[Unit]
Wants=xyz.service
After=xyz.service
_EOF_

I hope this is helpful to you or anyone else interested in this topic.

Thanks again.