Apr 9, 2020 5 min read
Varnish as a command line interface (CLI) which can control and change most of the operational parameters and the configuration of Varnish, without interrupting the running service.
sudo apt install varnish -y
sudo systemctl start varnish
sudo systemctl stop varnish
sudo systemctl restart varnish
In order to restart varnish I have to kill the process:
sudo killall varnishd
sudo /etc/init.d/varnish status
OR
sudo service varnish status
sudo varnishd -d -f /etc/varnish/default.vcl
/etc/varnish/default.vcl
Log in to the Varnish server and enter the following command:
sudo netstat -tulpn
Look for the following output in particular:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 32614/varnishd
tcp 0 0 127.0.0.1:58484 0.0.0.0:* LISTEN 32604/varnishd
tcp 0 0 :::8080 :::* LISTEN 26822/httpd
tcp 0 0 ::1:48509 :::* LISTEN 32604/varnishd
Until now we’ve been running with Varnish on a high port, for testing purposes. You should test your application and if it works OK we can switch, so Varnish will be running on port 80 and your web server on a high port.
sudo pkill varnishd
and stop your web server. Edit the configuration for your web server and make it bind to port 8080 instead of 80. Now open the Varnish default.vcl and change the port of the default backend to 8080.
sudo varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000
sudo apt-get remove --auto-remove varnish
sudo apt-get purge --auto-remove varnish
Installing and configuring Varnish