About Squid proxy servers

Note:
This documentation has moved to a new home! Please update your bookmarks to the new URL for the up-to-date version of this page.

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.