Varnish is distributed in the Ubuntu package repositories, but the version there might be out of date, so I generally use the packages provided by varnish-cache.org. However, Varnish only provide packages for Ubuntu’s LTS releases, not all the intermediate releases. These packages might still work on the intermediate releases.
sudo apt-get install apt-transport-https cd /tmp curl https://repo.varnish-cache.org/GPG-key.txt | sudo apt-key add - echo "deb https://repo.varnish-cache.org/ubuntu/ wheezy varnish-4.1" > /tmp/varnish-cache.list sudo copy /tmp/varnish-cache.list /etc/apt/sources.list.d/ sudo apt-get update sudo apt-get install varnish