【问题标题】:Can't get varnish to see backend无法获得清漆以查看后端
【发布时间】:2018-10-02 12:45:52
【问题描述】:

我在 OSX 上本地安装了 Varnish 来测试它。我有一个在 localhost:8085 上运行的工作后端,它返回 200。我使用 Brew 安装了 varnish,但没有运行 Brew 服务,而是使用

运行 Varnish
varnishd -n /usr/local/var/varnish -f /usr/local/etc/varnish/default.vcl -T 127.0.0.1:8085 -a 127.0.0.1:8090 -F

打印出来的

Debug: Platform: Darwin,17.5.0,x86_64,-jnone,-sdefault,-sdefault,-hcritbit
Debug: Child (57659) Started
Info: Child (57659) said Child starts

并在/usr/local/var/varnish 中创建一个vcl_boot.* 文件夹

当我转到 127.0.0.1:8090 时,我看到 varnish 正在运行,但只是得到

Error 503 Backend fetch failed
Backend fetch failed

我的/usr/local/etc/varnish/default.vcl 几乎是默认值:

#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.

# Marker to tell the VCL compiler that this VCL has been adapted to the
# new 4.0 format.
vcl 4.0;

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

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

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

有人知道我可能会错过什么吗?

谢谢!

【问题讨论】:

    标签: varnish varnish-vcl


    【解决方案1】:

    在你运行 Varnish 的命令中,我认为你错误地使用了-T 127.0.0.1:8085-T 开关用于:

    在指定地址和端口上提供管理接口。

    因此,您将 Varnish 管理界面绑定到与后端相同的端口。想知道为什么无论如何都不会失败。

    【讨论】:

    • 我正在运行 Varnish 6,当我执行帮助命令时,它显示 -T address[:port]CLI address 我可以提供与您所看到的不同的版本吗?
    • 我不这么认为。只需为该交换机设置一个不同的端口即可。它与后端的端口无关。
    • 谢谢,刚刚去掉-T,后端端口在VLC里设置好了
    猜你喜欢
    • 1970-01-01
    • 2016-09-21
    • 1970-01-01
    • 2014-10-16
    • 2017-11-24
    • 2021-10-10
    • 2017-07-21
    • 2018-07-18
    • 2014-10-25
    相关资源
    最近更新 更多