Varnish 上出现错误 503 服务不可用,但 varnishlog 未显示任何错误

Varnish 上出现错误 503 服务不可用,但 varnishlog 未显示任何错误

我有一台运行 Varnish 和 nginx 的服务器。前端网站报503错误:

错误 503 服务不可用

暂停服务

上师冥想:
XID:317911182

优化缓存服务器

这是的内容/etc/varnish/foo.vcl

backend default {
  .host = "127.0.0.1";
  .port = "8080";
  .connect_timeout = 1s;
  .first_byte_timeout = 90s;
  .between_bytes_timeout = 90s;
}

varnishlog显然没有显示任何问题:

0 CLI          - Rd ping
0 CLI          - Wr 200 19 PONG 1486463718 1.0
0 CLI          - Rd ping
0 CLI          - Wr 200 19 PONG 1486463721 1.0
0 CLI          - Rd ping
0 CLI          - Wr 200 19 PONG 1486463724 1.0
0 CLI          - Rd ping
0 CLI          - Wr 200 19 PONG 1486463727 1.0

但是,本地主机上的 8080 端口上没有运行任何服务:

server# netstat -anp | grep 8080
server# telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

事实上,nginx 日志在尝试连接时报告了一个错误:

2017/02/07 11:51:11 [error] 2008#0: *188 connect() failed (111: Connection refused) while connecting to upstream, client: 10.2.3.4, server: _, request: "GET /mydir/ HTTP/1.1", upstream: "http://127.0.0.1:8080/mydir/", host: "myhost.example.com"

我可以检查什么来进一步解决问题?

答案1

以下几行显示正常操作 - Varnish 正在检查其缓存是否正常。这是正常现象,与后端连接无关。

     0 CLI            - Rd ping
     0 CLI            - Wr 200 19 PONG 1486473078 1.0

如果后端配置了健康检查,您将看到类似以下内容:

清漆日志输出:

     0 CLI            - Rd ping
     0 CLI            - Wr 200 19 PONG 1486473075 1.0
     0 Backend_health - boot.default Still sick ------- 1 3 3 0.000000 0.000000
     0 Backend_health - boot.default Still sick ------- 0 3 3 0.000000 0.000000

或者

 32771 Timestamp      b Start: 1486473576.634500 0.000000 0.000000
 32771 BereqMethod    b GET
 32771 BereqURL       b /
 32771 BereqProtocol  b HTTP/1.1
 32771 BereqHeader    b Host: 127.0.0.1:8080
 32771 BereqHeader    b User-Agent: curl/7.51.0
 32771 BereqHeader    b Accept: */*
 32771 BereqHeader    b X-Forwarded-For: 127.0.0.1
 32771 BereqHeader    b Accept-Encoding: gzip
 32771 BereqHeader    b X-Varnish: 32771
 32771 VCL_call       b BACKEND_FETCH
 32771 VCL_return     b fetch
 32771 FetchError     b no backend connection

默认.vlc:

backend default {
    .host = "127.0.0.1";
    .port = "8081";
    .probe = {
        .url = "/status";
        .timeout = 60 ms;
        .interval = 10s;
        .window = 3;
        .threshold = 3;
    }
}

相关内容