Solved. See my solution below My system:
1. varnish 6
2.Centos 7 controlled on cwp pro panel,
3.webserver configuration:
Nginx & Varnish & Apache ([Varnish Conf])
Additional Options: php-cgi/suphp, nginx/php-fpm, apache/php-fpm, proxy, varnish cache, HTTP: Nginx (80) --> Varnish (82) --> Apache (8181)
HTTPS: Nginx (443) --> Varnish (82) --> Apache (8181)
** By default this will enable Nginx&Apache for all domains while Varnish you can enable additionally for domains you need.
I got the following error message:
# systemctl status varnish.service
● varnish.service - Varnish Cache, a high-performance HTTP accelerator
Loaded: loaded (/usr/lib/systemd/system/varnish.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/varnish.service.d
└─override.conf
Active: failed (Result: exit-code) since Wed 2020-11-18 21:50:41 GMT; 24s ago
Process: 32248 ExecStart=/usr/sbin/varnishd -j unix, user=vcache -F -a :82 -T <IP Address>:8443 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m (code=exited, status=2)
Main PID: 17031 (code=exited, status=0/SUCCESS)
systemd[1]: Starting Varnish Cache, a high-performance HTTP accelerator... varnishd[32248]: Error: Unix jail: vcache user not found.
varnishd[32248]: (-? gives usage)
systemd[1]: varnish.service: control process exited, code=exited status=2
systemd[1]: Failed to start Varnish Cache, a high-performance HTTP accelerator.
systemd[1]: Unit varnish.service entered failed state.
systemd[1]: varnish.service failed.
my /lib/systemd/system/varnish.service looks like this:
ExecStart=/usr/sbin/varnishd \
-a :6081 \
-a localhost:8443,PROXY \
-p feature=+http2 \
-f /etc/varnish/default.vcl \
-s malloc,256m
ExecReload=/usr/sbin/varnishreload
[Install]
WantedBy=multi-user.target
My systemctl edit varnish.service. I want varnish to listen to port 82
[Service]
ExecStart=
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a hostname:82 -T localhost:8443 -f /etc/varnish/default.vcl -S /etc/varnish/secret$
my /etc/varnish/default.vcl is just:
vcl 4.0;
backend default { .host = "server IP"; .port = "8181";}
include "/etc/varnish/conf.d/vhosts.conf";
What am I going wrong please? varnish will not restart.
Solution
I simply changed the localhost:8443 to localhost:6081 below. So the correct file in systemctl edit varnish.service is below. I went further to open port 82 on the firewall, systemctl daemon-reload, systemctl start varnish.
Hope this helps others.
[Service]
ExecStart=
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a <IP>:82 -T localhost: -f /etc/varnish/default.vcl -S /etc/varnish/secret$
ExecStart=/usr/sbin/varnishd \
-a :6081 \
-a localhost:8443,PROXY \
-p feature=+http2 \
-f /etc/varnish/default.vcl \
-s malloc,256m
ExecReload=/usr/sbin/varnishreload
[Install] WantedBy=multi-user.target
My systemctl edit varnish.service.
[Service] ExecStart= ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a hostname:82 -T localhost:8443 -f /etc/varnish/default.vcl -S /etc/varnish/secret$ -s malloc,1024m