Reputation: 725
Varnish 4.1.1 completely ignores settings in the /etc/default/varnish file on Ubuntu 16.04 LTS. I'm looking for a solution.
Result of /bin/systemctl status varnish.service
Warning: Journal has been rotated since unit was started. Log output is incomple
lines 1-14/14 (END)
● varnish.service - Varnish HTTP accelerator
Loaded: loaded (/lib/systemd/system/varnish.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-01-09 01:24:09 UTC; 15h ago
Docs: https://www.varnish-cache.org/docs/4.1/
man:varnishd
Main PID: 9470 (varnishd)
Tasks: 218
Memory: 67.5M
CPU: 45.584s
CGroup: /system.slice/varnish.service
├─9470 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret
└─9483 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
Upvotes: 3
Views: 3235
Reputation: 676
On ubuntu 19.04 :
sudo vi /etc/systemd/system/multi-user.target.wants/varnish.service (change the port)
sudo systemctl daemon-reload && sudo systemctl restart varnish && sudo systemctl status varnish
curl localhost
Upvotes: 3
Reputation: 170
This is, apparently, intentional behaviour in upstream Debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749272
/etc/default/varnish is used by /etc/init.d/varnish exclusively on purpose.
"If you want to use /etc/default/varnish on your own, you can override /lib/systemd/system/varnish.service in /etc/systemd/system/varnish.service, but I'll recommend you just write the wanted commandline options in /etc/systemd/system/varnish.service, instead of reading /etc/default/varnish "
varnish.service is in .INI format. This tutorial gives an example for Debian: http://deshack.net/how-to-varnish-listen-port-80-systemd/
Varnish have added in the official docs:
e.g. the varnish.service on the Varnish I've just set up on 16.04 has this line (the box is called cache1):
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -s file,/var/lib/varnish/cache1/varnish_storage.bin,85G -n cache1
Once you've changed this do not forget to reload systemd:
systemctl daemon-reload
Then restart Varnish. Check your results with /bin/systemctl status varnish.service .
tl;dr you need to put your config in both places.
Upvotes: 3
Reputation: 11960
By default Varnish
will try to load the default.vcl
which is located at this path /etc/varnish/default.vcl
as you see in here:
CGroup: /system.slice/varnish.service
├─9470 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret
└─9483 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret
if you would like to load another file which will be located at another path then you need to open this file /etc/varnish/varnish.params
and modify the value of this line:
# Main configuration file. You probably want to change it.
VARNISH_VCL_CONF=/etc/varnish/default.vcl
This works with Varnish 4+
Upvotes: 1