首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >清漆default.vcl

清漆default.vcl
EN

Stack Overflow用户
提问于 2017-09-20 15:02:48
回答 2查看 2.6K关注 0票数 0

我刚刚在我的开发服务器上安装了清漆,它正在运行,没有改变任何配置。所以现在它只要求Apache提供响应并将其传回。

嗯,我是个新手,我正在尝试缓存javascript、css和图像来测试清漆。我的问题是,如果我写返回(查找);在vcl_recv中给我错误的服务清漆重新启动!!

代码语言:javascript
复制
vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
  .host = "127.0.0.1";
  .port = "80";
}

sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you don't need,
# rewriting the request, etc.
#hash_data(req.url);
#if (req.http.host) {
#    hash_data(req.http.host);
#} else {
#    hash_data(server.ip);
#}
return (lookup);
}

sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.

 }

sub vcl_deliver {
# Happens when we have all the pieces we need, and are about to send the
# response to the client.
#
# You can do accounting or modifying the final object here.
}

default.vcl中的此配置在重新启动时给出了下一个错误:

代码语言:javascript
复制
Job for varnish.service failed. See 'systemctl status varnish.service' and 'journalctl -xn' for details.

救救我!!

EN

回答 2

Stack Overflow用户

发布于 2017-09-20 16:24:01

你可以这样做:

代码语言:javascript
复制
sub vcl_recv {
  if (req.url ~ "(?i)\.(jpeg|jpg|png|gif|ico|js|css)$") {
      unset req.http.Cookie;
      return (hash);
  } else {
      return (pass);
  }
}

要获得一个扩展的答案,您可能需要查看Varnix3 3https://serverfault.com/a/551283/426146中的答案。

票数 0
EN

Stack Overflow用户

发布于 2019-10-04 14:28:48

问题是在default.vcl中端口是80。端口必须是web服务器正在监听的端口,例如8080。必须在8080中配置web服务器。在Debian中,您的/etc/systemd/system/varnish.service文件的端口必须更改为80。

ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/ -s malloc,512 m

然后,使用您的浏览器,您正在连接到80清漆和清漆询问web服务器从8080页和文件(缓存后第一次命中)。

如果文件不存在,请运行:

cp /lib/systemd/system/varnish.service /etc/systemd/system/ systemctl守护进程-重新加载&& systemctl状态清漆

并开始使用该文件,然后可以在/etc/varnish/default.vcl中输入代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46325569

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档