gpt4 book ai didi

php - Varnish:503 后端获取失败/Varnishlog 说:FetchError 没有后端

转载 作者:行者123 更新时间:2023-12-03 17:45:32 35 4
gpt4 key购买 nike

编辑(1):
“.timeout”值似乎没有任何作用。立即显示“503后端提取失败”错误

原始说明:
我对 Varnish 很陌生。任何帮助表示赞赏。每次尝试使用Varnish调用网页时,我都会不断收到以下错误消息:

<body>
<h1>Error 503 Backend fetch failed</h1>
<p>Backend fetch failed</p>
<h3>Guru Meditation:</h3>
<p>XID: 3</p>
<hr>
<p>Varnish cache server</p>
</body>

背景::我有一个文件index.php:

下面的作品:
curl --header "Host: serverx.dev" 192.168.56.10:8080/index.php    

以下内容不起作用,并引发“后端获取失败”错误:
curl --header "Host: serverx.dev" 192.168.56.10:80/index.php    

我使用以下内容:
Virtualbox 5.0.32 r112930
Host operating system: Windows 7 (64-bit)
Guest operating system: Debian Jessie (minimal install)
Apache2 -----port 8080
varnish-4.1.5 revision 2c82b1c -----port 80

default.vcl:
vcl 4.0;
# import default varnish library
import std;
import directors;
backend server1 {
.host = "192.168.56.10";
.port = "8080";
.probe = {
.url = "/robots.txt";
.interval = 5s;
.timeout = 50s;
.window = 5;
.threshold = 3;
}
}
sub vcl_init {
new cluster = directors.round_robin();
cluster.add_backend(server1);
}

以下是当前的 Varnish 状态:
root@debian:/etc/varnish# ps -ef | grep varnish
varnish 4210 1 0 11:26 ? 00:00:00 /usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
vcache 4211 4210 0 11:26 ? 00:00:00 /usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
root 4632 1470 0 11:40 pts/0 00:00:00 grep varnish

并且:
root@debian:/etc/varnish# netstat -anp | grep varnish
tcp 0 0 127.0.0.1:6082 0.0.0.0:* LISTEN 4210/varnishd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4210/varnishd
tcp6 0 0 ::1:6082 :::* LISTEN 4210/varnishd
tcp6 0 0 :::80 :::* LISTEN 4210/varnishd
unix 2 [ ] DGRAM 35213 4210/varnishd

Apache2:
root@debian:/etc/varnish# netstat -anp | grep apache2
tcp6 0 0 :::443 :::* LISTEN 4461/apache2
tcp6 0 0 :::8080 :::* LISTEN 4461/apache2

Varnishlog提供以下输出
-   BereqHeader    X-Varnish: 51
- VCL_call BACKEND_FETCH
- VCL_return fetch
- FetchError Director cluster returned no backend
- FetchError No backend
- Timestamp Beresp: 1490091185.165509 0.000027 0.000027
- Timestamp Error: 1490091185.165513 0.000030 0.000004
- BerespProtocol HTTP/1.1
- BerespStatus 503
- BerespReason Service Unavailable
- BerespReason Backend fetch failed
- BerespHeader Date: Tue, 21 Mar 2017 10:13:05 GMT
- BerespHeader Server: Varnish
- VCL_call BACKEND_ERROR

我很乐意提供更多信息。

最佳答案

问题似乎出在default.vcl中。
更改.probe中的.url值后, Varnish 即可正常工作。

之前:

backend server1 {
.host = "192.168.56.10";
.port = "8080";
.probe = {
.url = "/robots.txt";
.interval = 5s;
.timeout = 50s;
.window = 5;
.threshold = 3;
}
}

现在:(此有效)
backend server1 {
.host = "192.168.56.10";
.port = "8080";
.probe = {
.url = "/"; -------The change was made here
.interval = 5s;
.timeout = 50s;
.window = 5;
.threshold = 3;
}
}

关于php - Varnish:503 后端获取失败/Varnishlog 说:FetchError 没有后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42927911/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com