为什么我更改端口后 varnish 没有重新启动

为什么我更改端口后 varnish 没有重新启动

解决了。​​请参阅下面的解决方案 我的系统:

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.

我收到以下错误消息:

    # 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.

我的 /lib/systemd/system/varnish.service 看起来像这样:

    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

我的 systemctl 编辑 varnish.service。我想让 varnish 监听端口 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$

我的 /etc/varnish/default.vcl 只是:

    vcl 4.0;
backend default { .host = "server IP"; .port = "8181";}
include "/etc/varnish/conf.d/vhosts.conf";

请问我哪里出错了?Varnish 无法重新启动。

解决方案

我下面只是将 localhost:8443 改为 localhost:6081。因此 systemctl edit varnish.service 中的正确文件如下。我进一步在防火墙上打开端口 82,systemctl daemon-reload,systemctl start varnish。

希望这对其他人有帮助。

[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

[安装] WantedBy=multi-user.target


My systemctl edit varnish.service. 

[服务] ExecStart= ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a 主机名:82 -T localhost:8443 -f /etc/varnish/default.vcl -S /etc/varnish/secret$ -s malloc,1024m


答案1

您收到的错误包含您的问题的答案:

Error: Unix jail: vcache user not found.

并且此错误是systemd由您的配置触发的-j unix,user=vcache

删除该-j参数,或者确保该vcache用户存在。

相关内容