【问题标题】:ELB ->varnish-->nginx-->>ELB--->>nginx---->>>magentoELB ->varnish-->nginx-->>ELB--->>nginx---->>>magento
【发布时间】:2021-03-19 08:37:32
【问题描述】:

502 错误网关 你好!帮助设置。 有 2 个 ec2。他们在 alb aws 中与一个安全组联合在不同的目标组中。 1个ec2清漆和nginx。 2 ec2 magento nginx。清漆 80 - >> nging >> alb >> magento。 Varnish 502报错,请帮忙...

ec2 清漆 nginx.conf

    worker_processes  1;

       events {
    worker_connections 1024;
     }

http {
include       mime.types;
sendfile on;
default_type  application/octet-stream;

keepalive_timeout  65;

server_tokens off;

server {
listen      127.0.0.1:8080;

resolver 8.8.8.8 valid=10s;
        resolver_timeout 10s;
location / {

 
 set $backend_servers http://111-1087349.eu-central-1.elb.amazonaws.com;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header Ssl-Offloaded $scheme;
 fastcgi_buffer_size 32k;
 fastcgi_busy_buffers_size 32k;
 fastcgi_buffers 4 32k;
 proxy_buffer_size   64k;
 proxy_buffers   4 64k;
 proxy_busy_buffers_size   64k;
 proxy_pass $backend_servers;
 proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Ssl-Offloaded "1";

 }
}
}

EC2 magento 配置

upstream fastcgi_backend {
  server  unix:/var/run/php/php7.2-fpm.sock;
}

server {

  listen 80;


  server_name 111-1087349.eu-central-1.elb.amazonaws.com;
  set $MAGE_ROOT /var/www/html/magento2;
  set $MAGE_DEBUG_SHOW_ARGS 1;
  fastcgi_buffer_size 32k;
  fastcgi_busy_buffers_size 32k;
  fastcgi_buffers 4 32k;
  proxy_buffer_size   64k;
  proxy_buffers   4 64k;
  proxy_busy_buffers_size   64k;

  include /var/www/html/magento2/nginx.conf.sample;


}

清漆/default.vcl

# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 5
vcl 4.0;

import std;
# The minimal Varnish version is 5.0
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'

backend default {
    .host = "127.0.0.1";
    .port = "";
    .first_byte_timeout = 600s;
    
}

acl purge {

}

sub vcl_recv {
    if (req.method == "PURGE") {
        if (client.ip !~ purge) {
            return (synth(405, "Method not allowed"));
        }
        # To use the X-Pool header for purging varnish during automated deployments, make sure the X-Pool header
        # has been added to the response in your backend server config. This is used, for example, by the
        # capistrano-magento2 gem for purging old content from varnish during it's deploy routine.
        if (!req.http.X-Magento-Tags-Pattern && !req.http.X-Pool) {
            return (synth(400, "X-Magento-Tags-Pattern or X-Pool header required"));
        }
        if (req.http.X-Magento-Tags-Pattern) {
          ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
        }
        if (req.http.X-Pool) {
          ban("obj.http.X-Pool ~ " + req.http.X-Pool);
        }
        return (synth(200, "Purged"));
    }

    if (req.method != "GET" &&
        req.method != "HEAD" &&
        req.method != "PUT" &&
        req.method != "POST" &&
        req.method != "TRACE" &&
        req.method != "OPTIONS" &&
        req.method != "DELETE") {
          /* Non-RFC2616 or CONNECT which is weird. */
          return (pipe);
    }

    # We only deal with GET and HEAD by default
    if (req.method != "GET" && req.method != "HEAD") {
        return (pass);
    }

    # Bypass shopping cart, checkout and search requests
    if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
        return (pass);
    }

    # Bypass health check requests
    if (req.url ~ "/pub/health_check.php") {
        return (pass);
    }

    # Set initial grace period usage status
    set req.http.grace = "none";

    # normalize url in case of leading HTTP scheme and domain
    set req.url = regsub(req.url, "^http[s]?://", "");

    # collect all cookies
    std.collect(req.http.Cookie);

    # Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression
    if (req.http.Accept-Encoding) {
        if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
            # No point in compressing these
            unset req.http.Accept-Encoding;
        } elsif (req.http.Accept-Encoding ~ "gzip") {
            set req.http.Accept-Encoding = "gzip";
        } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
            set req.http.Accept-Encoding = "deflate";
        } else {
            # unknown algorithm
            unset req.http.Accept-Encoding;
        }
    }

    # Remove all marketing get parameters to minimize the cache objects
    if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") {
        set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", "");
        set req.url = regsub(req.url, "[?|&]+$", "");
    }

    # Static files caching
    if (req.url ~ "^/(pub/)?(media|static)/") {
        # Static files should not be cached by default
        return (pass);

        # But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
        #unset req.http.Https;
        #unset req.http.X-Forwarded-Proto;
        #unset req.http.Cookie;
    }

    return (hash);
}

sub vcl_hash {
    if (req.http.cookie ~ "X-Magento-Vary=") {
        hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));
    }

    # For multi site configurations to not cache each other's content
    if (req.http.host) {
        hash_data(req.http.host);
    } else {
        hash_data(server.ip);
    }

    # To make sure http users don't see ssl warning
    if (req.http.X-Forwarded-Proto) {
        hash_data(req.http.X-Forwarded-Proto);
    }
    

    if (req.url ~ "/graphql") {
        call process_graphql_headers;
    }
}

sub process_graphql_headers {
    if (req.http.Store) {
        hash_data(req.http.Store);
    }
    if (req.http.Content-Currency) {
        hash_data(req.http.Content-Currency);
    }
}

sub vcl_backend_response {

    set beresp.grace = 3d;

    if (beresp.http.content-type ~ "text") {
        set beresp.do_esi = true;
    }

    if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") {
        set beresp.do_gzip = true;
    }

    if (beresp.http.X-Magento-Debug) {
        set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;
    }

    # cache only successfully responses and 404s
    if (beresp.status != 200 && beresp.status != 404) {
        set beresp.ttl = 0s;
        set beresp.uncacheable = true;
        return (deliver);
    } elsif (beresp.http.Cache-Control ~ "private") {
        set beresp.uncacheable = true;
        set beresp.ttl = 86400s;
        return (deliver);
    }

    # validate if we need to cache it and prevent from setting cookie
    if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
        unset beresp.http.set-cookie;
    }

   # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
   if (beresp.ttl <= 0s ||
       beresp.http.Surrogate-control ~ "no-store" ||
       (!beresp.http.Surrogate-Control &&
       beresp.http.Cache-Control ~ "no-cache|no-store") ||
       beresp.http.Vary == "*") {
        # Mark as Hit-For-Pass for the next 2 minutes
        set beresp.ttl = 120s;
        set beresp.uncacheable = true;
    }

    return (deliver);
}

sub vcl_deliver {
    if (resp.http.X-Magento-Debug) {
        if (resp.http.x-varnish ~ " ") {
            set resp.http.X-Magento-Cache-Debug = "HIT";
            set resp.http.Grace = req.http.grace;
        } else {
            set resp.http.X-Magento-Cache-Debug = "MISS";
        }
    } else {
        unset resp.http.Age;
    }

    # Not letting browser to cache non-static files.
    if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") {
        set resp.http.Pragma = "no-cache";
        set resp.http.Expires = "-1";
        set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
    }

    unset resp.http.X-Magento-Debug;
    unset resp.http.X-Magento-Tags;
    unset resp.http.X-Powered-By;
    unset resp.http.Server;
    unset resp.http.X-Varnish;
    unset resp.http.Via;
    unset resp.http.Link;
}

sub vcl_hit {
    if (obj.ttl >= 0s) {
        # Hit within TTL period
        return (deliver);
    }
    if (std.healthy(req.backend_hint)) {
        if (obj.ttl + s > 0s) {
            # Hit after TTL expiration, but within grace period
            set req.http.grace = "normal (healthy server)";
            return (deliver);
        } else {
            # Hit after TTL and grace expiration
            return (miss);
        }
    } else {
        # server is not healthy, retrieve from cache
        set req.http.grace = "unlimited (unhealthy server)";
        return (deliver);
    }
}

清漆日志

<< BeReq    >> 294975    
-   Begin          bereq 294974 fetch
-   Timestamp      Start: 1607391195.988343 0.000000 0.000000
-   BereqMethod    GET
-   BereqURL       /
-   BereqProtocol  HTTP/1.1
-   BereqHeader    X-Forwarded-Proto: http
-   BereqHeader    X-Forwarded-Port: 80
-   BereqHeader    Host: 111-1087349.eu-central-1.elb.amazonaws.com
-   BereqHeader    X-Amzn-Trace-Id: Root=1-5fced7db-0ce3d2c16cb26ad3467fe8e7
-   BereqHeader    Upgrade-Insecure-Requests: 1
-   BereqHeader    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
-   BereqHeader    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
-   BereqHeader    Accept-Language: ru-RU,ru;q=0.9
-   BereqHeader    X-Forwarded-For: 78.84.157.24, 172.31.24.118
-   BereqHeader    grace: none
-   BereqHeader    Accept-Encoding: gzip
-   BereqHeader    X-Varnish: 294975
-   VCL_call       BACKEND_FETCH
-   VCL_return     fetch
-   BackendOpen    194 boot.default 127.0.0.1 8080 127.0.0.1 42794
-   BackendStart   127.0.0.1 8080
-   Timestamp      Bereq: 1607391195.988456 0.000112 0.000112
-   Timestamp      Beresp: 1607391195.993930 0.005587 0.005475
-   BerespProtocol HTTP/1.1
-   BerespStatus   502
-   BerespReason   Bad Gateway
-   BerespHeader   Server: nginx
-   BerespHeader   Date: Tue, 08 Dec 2020 01:33:15 GMT
-   BerespHeader   Content-Type: text/html
-   BerespHeader   Content-Length: 524
-   BerespHeader   Connection: keep-alive
-   TTL            RFC -1 10 0 1607391196 1607391196 1607391195 0 0
-   VCL_call       BACKEND_RESPONSE
-   TTL            VCL -1 259200 0 1607391196
-   TTL            VCL 0 259200 0 1607391196
-   VCL_return     deliver
-   BerespUnset    Content-Length: 524
-   BerespHeader   Content-Encoding: gzip
-   BerespHeader   Vary: Accept-Encoding
-   Storage        malloc Transient
-   ObjProtocol    HTTP/1.1
-   ObjStatus      502
-   ObjReason      Bad Gateway
-   ObjHeader      Server: nginx
-   ObjHeader      Date: Tue, 08 Dec 2020 01:33:15 GMT
-   ObjHeader      Content-Type: text/html
-   ObjHeader      Content-Encoding: gzip
-   ObjHeader      Vary: Accept-Encoding
-   Fetch_Body     3 length -
-   Gzip           G F E 524 170 80 1280 1290
-   BackendReuse   194 boot.default
-   Timestamp      BerespBody: 1607391195.994121 0.005778 0.000191
-   Length         170
-   BereqAcct      601 0 601 150 0 150
-   End            

*   << Request  >> 294974    
-   Begin          req 294973 rxreq
-   Timestamp      Start: 1607391195.988271 0.000000 0.000000
-   Timestamp      Req: 1607391195.988271 0.000000 0.000000
-   ReqStart       172.31.24.118 34730
-   ReqMethod      GET
-   ReqURL         /
-   ReqProtocol    HTTP/1.1
-   ReqHeader      X-Forwarded-For: 78.84.157.24
-   ReqHeader      X-Forwarded-Proto: http
-   ReqHeader      X-Forwarded-Port: 80
-   ReqHeader      Host: 111-1087349.eu-central-1.elb.amazonaws.com
-   ReqHeader      X-Amzn-Trace-Id: Root=1-5fced7db-0ce3d2c16cb26ad3467fe8e7
-   ReqHeader      Cache-Control: max-age=0
-   ReqHeader      Upgrade-Insecure-Requests: 1
-   ReqHeader      User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
-   ReqHeader      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
-   ReqHeader      Accept-Encoding: gzip, deflate
-   ReqHeader      Accept-Language: ru-RU,ru;q=0.9
-   ReqUnset       X-Forwarded-For: 78.84.157.24
-   ReqHeader      X-Forwarded-For: 78.84.157.24, 172.31.24.118
-   VCL_call       RECV
-   ReqHeader      grace: none
-   ReqURL         /
-   ReqUnset       Accept-Encoding: gzip, deflate
-   ReqHeader      Accept-Encoding: gzip
-   VCL_return     hash
-   VCL_call       HASH
-   VCL_return     lookup
-   VCL_call       MISS
-   VCL_return     fetch
-   Link           bereq 294975 fetch
-   Timestamp      Fetch: 1607391195.994196 0.005925 0.005925
-   RespProtocol   HTTP/1.1
-   RespStatus     502
-   RespReason     Bad Gateway
-   RespHeader     Server: nginx
-   RespHeader     Date: Tue, 08 Dec 2020 01:33:15 GMT
-   RespHeader     Content-Type: text/html
-   RespHeader     Content-Encoding: gzip
-   RespHeader     Vary: Accept-Encoding
-   RespHeader     X-Varnish: 294974
-   RespHeader     Age: 0
-   RespHeader     Via: 1.1 varnish (Varnish/5.2)
-   VCL_call       DELIVER
-   RespUnset      Age: 0
-   RespHeader     Pragma: no-cache
-   RespHeader     Expires: -1
-   RespHeader     Cache-Control: no-store, no-cache, must-revalidate, max-age=0
-   RespUnset      Server: nginx
-   RespUnset      X-Varnish: 294974
-   RespUnset      Via: 1.1 varnish (Varnish/5.2)
-   VCL_return     deliver
-   Timestamp      Process: 1607391195.994214 0.005943 0.000018
-   RespHeader     Content-Length: 170
-   RespHeader     Connection: keep-alive
-   Timestamp      Resp: 1607391195.994238 0.005967 0.000024
-   ReqAcct        589 0 589 276 170 446
-   End            

*   << Session  >> 294973    
-   Begin          sess 0 HTTP/1
-   SessOpen       172.31.24.118 34730 a0 172.31.36.3 80 1607391195.988228 42
-   Link           req 294974 rxreq
-   SessClose      RX_TIMEOUT 5.011
-   End  

(EC2 Varnish) nginx/error.log

2020/12/08 01:32:48 [error] 18840#18840: *9 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://18.158.86.156:80/", host: "172.31.36.3"
2020/12/08 01:33:48 [error] 18840#18840: *9 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://18.158.86.156:80/", host: "172.31.36.3"

curl -I -v --location-trusted 'http://111-1087349.eu-central-1.elb.amazonaws.com'

* Rebuilt URL to: http://111-1087349.eu-central-1.elb.amazonaws.com/
*   Trying 35.156.193.122...
* TCP_NODELAY set
* Connected to 111-1087349.eu-central-1.elb.amazonaws.com (35.156.193.122) port 80 (#0)
> HEAD / HTTP/1.1
> Host: 111-1087349.eu-central-1.elb.amazonaws.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 502 Bad Gateway
HTTP/1.1 502 Bad Gateway
< Server: awselb/2.0
Server: awselb/2.0
< Date: Tue, 08 Dec 2020 01:37:37 GMT
Date: Tue, 08 Dec 2020 01:37:37 GMT
< Content-Type: text/html
Content-Type: text/html
< Content-Length: 122
Content-Length: 122
< Connection: keep-alive
Connection: keep-alive

【问题讨论】:

    标签: amazon-web-services nginx magento varnish


    【解决方案1】:

    此设置中有许多活动部件,要弄清楚是什么触发了HTTP/502 错误并不容易。

    谁的错?

    但是,我们已经可以消除以下组件:

    • 您的入口点 ELB 没有问题
    • 清漆没有问题
    • 作为 Varnish 后端的 Nginx 没有问题

    根据您的日志,实际上是 http://111-1087349.eu-central-1.elb.amazonaws.com 超时。

    这意味着您的 Magento EC2 节点导致了这个错误。

    如何测试和解决这个问题?

    第二层 ELB 可能位于一组 Magento 服务器的前面。尝试直接向一堆 Magento 服务器发送请求,看看加载需要多长时间。

    如果需要相当长的时间,请尝试增加第二层 ELB 上的首字节超时时间

    考虑简化您的设置

    您至少有 5 个跃点要通过。太多了。

    也许您可以简化设置,并减少一些开销。

    这里有一个建议:

    ELB -> Varnish -> Nginx + PHP-FPM
    
    • 在 ELB 上接受 HTTP 和 HTTPS 连接,并将纯 HTTP 请求转发给 Varnish
    • 对 Varnish 执行缓存逻辑并代理对 Magento 服务器的请求
    • Magento 服务器具有 Nginx 和 PHP-FPM 来托管 Magento 内容

    快速说明: Varnish Software 在 AWS 市场上提供托管 Varnish 图像。见https://aws.amazon.com/marketplace/seller-profile?id=263c0208-6a3a-435d-8728-fa2514202fd0。这使您甚至可以以便宜的价格启动 Varnish Enterprise,并使用一些高级功能,而无需预先购买许可证密钥。

    【讨论】:

      【解决方案2】:

      我更改了/etc/default/varnish/中的设置

      DAEMON_OPTS="-a :80 \
                   -T localhost:6082 \
                   -f /etc/varnish/default.vcl \
                   -S /etc/varnish/secret \
                   -p http_resp_hdr_len=65536 \
                   -p http_resp_size=98304 \
                   -s malloc,256m"
      

      清漆日志 504

      *   << BeReq    >> 688137    
      -   Begin          bereq 131089 fetch
      -   Timestamp      Start: 1607433770.282822 0.000000 0.000000
      -   BereqMethod    GET
      -   BereqURL       /
      -   BereqProtocol  HTTP/1.1
      -   BereqHeader    Host: 172.31.46.83
      -   BereqHeader    User-Agent: ELB-HealthChecker/2.0
      -   BereqHeader    X-Forwarded-For: 172.31.32.16
      -   BereqHeader    grace: none
      -   BereqHeader    Accept-Encoding: gzip
      -   BereqHeader    X-Varnish: 688137
      -   VCL_call       BACKEND_FETCH
      -   VCL_return     fetch
      -   BackendOpen    25 boot.default 127.0.0.1 8080 127.0.0.1 50480
      -   BackendStart   127.0.0.1 8080
      -   Timestamp      Bereq: 1607433770.282866 0.000045 0.000045
      -   Timestamp      Beresp: 1607433890.296603 120.013782 120.013737
      -   BerespProtocol HTTP/1.1
      -   BerespStatus   504
      -   BerespReason   Gateway Time-out
      -   BerespHeader   Server: nginx
      -   BerespHeader   Date: Tue, 08 Dec 2020 13:24:50 GMT
      -   BerespHeader   Content-Type: text/html
      -   BerespHeader   Content-Length: 176
      -   BerespHeader   Connection: keep-alive
      -   TTL            RFC -1 10 0 1607433890 1607433890 1607433890 0 0
      -   VCL_call       BACKEND_RESPONSE
      -   TTL            VCL -1 259200 0 1607433890
      -   TTL            VCL 0 259200 0 1607433890
      -   VCL_return     deliver
      -   BerespUnset    Content-Length: 176
      -   BerespHeader   Content-Encoding: gzip
      -   BerespHeader   Vary: Accept-Encoding
      -   Storage        malloc Transient
      -   ObjProtocol    HTTP/1.1
      -   ObjStatus      504
      -   ObjReason      Gateway Time-out
      -   ObjHeader      Server: nginx
      -   ObjHeader      Date: Tue, 08 Dec 2020 13:24:50 GMT
      -   ObjHeader      Content-Type: text/html
      -   ObjHeader      Content-Encoding: gzip
      -   ObjHeader      Vary: Accept-Encoding
      -   Fetch_Body     3 length -
      -   Gzip           G F E 176 142 80 1056 1066
      -   BackendReuse   25 boot.default
      -   Timestamp      BerespBody: 1607433890.296911 120.014089 0.000308
      -   Length         142
      -   BereqAcct      159 0 159 155 0 155
      -   End            
      
      *   << Request  >> 131089    
      -   Begin          req 131088 rxreq
      -   Timestamp      Start: 1607433050.504919 0.000000 0.000000
      -   Timestamp      Req: 1607433050.504919 0.000000 0.000000
      -   ReqStart       172.31.32.16 25270
      -   ReqMethod      GET
      -   ReqURL         /
      -   ReqProtocol    HTTP/1.1
      -   ReqHeader      Host: 172.31.46.83
      -   ReqHeader      Connection: close
      -   ReqHeader      User-Agent: ELB-HealthChecker/2.0
      -   ReqHeader      Accept-Encoding: gzip, compressed
      -   ReqHeader      X-Forwarded-For: 172.31.32.16
      -   VCL_call       RECV
      -   ReqHeader      grace: none
      -   ReqURL         /
      -   ReqUnset       Accept-Encoding: gzip, compressed
      -   ReqHeader      Accept-Encoding: gzip
      -   VCL_return     hash
      -   VCL_call       HASH
      -   VCL_return     lookup
      -   Timestamp      Waitinglist: 1607433770.282748 719.777829 719.777829
      -   VCL_call       MISS
      -   VCL_return     fetch
      -   Link           bereq 688137 fetch
      -   Timestamp      Fetch: 1607433890.297005 839.792086 120.014257
      -   RespProtocol   HTTP/1.1
      -   RespStatus     504
      -   RespReason     Gateway Time-out
      -   RespHeader     Server: nginx
      -   RespHeader     Date: Tue, 08 Dec 2020 13:24:50 GMT
      -   RespHeader     Content-Type: text/html
      -   RespHeader     Content-Encoding: gzip
      -   RespHeader     Vary: Accept-Encoding
      -   RespHeader     X-Varnish: 131089
      -   RespHeader     Age: 0
      -   RespHeader     Via: 1.1 varnish (Varnish/5.2)
      -   VCL_call       DELIVER
      -   RespUnset      Age: 0
      -   RespHeader     Pragma: no-cache
      -   RespHeader     Expires: -1
      -   RespHeader     Cache-Control: no-store, no-cache, must-revalidate, max-age=0
      -   RespUnset      Server: nginx
      -   RespUnset      X-Varnish: 131089
      -   RespUnset      Via: 1.1 varnish (Varnish/5.2)
      -   VCL_return     deliver
      -   Timestamp      Process: 1607433890.297032 839.792114 0.000027
      -   RespHeader     Content-Length: 142
      -   RespHeader     Connection: close
      -   Timestamp      Resp: 1607433890.297058 839.792139 0.000025
      -   ReqAcct        127 0 127 276 142 418
      -   End            
      
      *   << BeReq    >> 163849    
      -   Begin          bereq 360454 fetch
      -   Timestamp      Start: 1607433770.319040 0.000000 0.000000
      -   BereqMethod    GET
      -   BereqURL       /
      -   BereqProtocol  HTTP/1.1
      -   BereqHeader    X-Forwarded-Proto: http
      -   BereqHeader    X-Forwarded-Port: 80
      -   BereqHeader    Host: 111-1249061354.eu-central-1.elb.amazonaws.com
      -   BereqHeader    X-Amzn-Trace-Id: Self=1-5fcf7cc2-206e963313365a3b4a1e8a49;Root=1-5fcf7b0b-6eab97737cf96be3401f278c
      -   BereqHeader    Ssl-Offloaded: http
      -   BereqHeader    X-Forwarded-Host: 111-1249061354.eu-central-1.elb.amazonaws.com
      -   BereqHeader    X-Real-IP: 127.0.0.1
      -   BereqHeader    Ssl-Offloaded: 1
      -   BereqHeader    User-Agent: curl/7.58.0
      -   BereqHeader    Accept: */*
      -   BereqHeader    X-Varnish: 327699
      -   BereqHeader    X-Varnish: 229386
      -   BereqHeader    X-Forwarded-For: 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237
      -   BereqHeader    grace: none
      -   BereqHeader    Accept-Encoding: gzip
      -   BereqHeader    X-Varnish: 163849
      -   VCL_call       BACKEND_FETCH
      -   VCL_return     fetch
      -   BackendOpen    31 boot.default 127.0.0.1 8080 127.0.0.1 50492
      -   BackendStart   127.0.0.1 8080
      -   Timestamp      Bereq: 1607433770.319087 0.000047 0.000047
      -   Timestamp      Beresp: 1607433890.320313 120.001274 120.001227
      -   BerespProtocol HTTP/1.1
      -   BerespStatus   504
      -   BerespReason   Gateway Time-out
      -   BerespHeader   Server: nginx
      -   BerespHeader   Date: Tue, 08 Dec 2020 13:24:50 GMT
      -   BerespHeader   Content-Type: text/html
      -   BerespHeader   Content-Length: 132
      -   BerespHeader   Connection: keep-alive
      -   TTL            RFC -1 10 0 1607433890 1607433890 1607433890 0 0
      -   VCL_call       BACKEND_RESPONSE
      -   TTL            VCL -1 259200 0 1607433890
      -   TTL            VCL 0 259200 0 1607433890
      -   VCL_return     deliver
      -   BerespUnset    Content-Length: 132
      -   BerespHeader   Content-Encoding: gzip
      -   BerespHeader   Vary: Accept-Encoding
      -   Storage        malloc Transient
      -   ObjProtocol    HTTP/1.1
      -   ObjStatus      504
      -   ObjReason      Gateway Time-out
      -   ObjHeader      Server: nginx
      -   ObjHeader      Date: Tue, 08 Dec 2020 13:24:50 GMT
      -   ObjHeader      Content-Type: text/html
      -   ObjHeader      Content-Encoding: gzip
      -   ObjHeader      Vary: Accept-Encoding
      -   Fetch_Body     3 length -
      -   Gzip           G F E 132 114 80 832 842
      -   BackendReuse   31 boot.default
      -   Timestamp      BerespBody: 1607433890.320496 120.001456 0.000183
      -   Length         114
      -   BereqAcct      601 0 601 155 0 155
      -   End            
      
      *   << Request  >> 360454    
      -   Begin          req 360453 rxreq
      -   Timestamp      Start: 1607433410.312548 0.000000 0.000000
      -   Timestamp      Req: 1607433410.312548 0.000000 0.000000
      -   ReqStart       172.31.18.237 49954
      -   ReqMethod      GET
      -   ReqURL         /
      -   ReqProtocol    HTTP/1.1
      -   ReqHeader      X-Forwarded-For: 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97
      -   ReqHeader      X-Forwarded-Proto: http
      -   ReqHeader      X-Forwarded-Port: 80
      -   ReqHeader      Host: 111-1249061354.eu-central-1.elb.amazonaws.com
      -   ReqHeader      X-Amzn-Trace-Id: Self=1-5fcf7cc2-206e963313365a3b4a1e8a49;Root=1-5fcf7b0b-6eab97737cf96be3401f278c
      -   ReqHeader      Ssl-Offloaded: http
      -   ReqHeader      X-Forwarded-Host: 111-1249061354.eu-central-1.elb.amazonaws.com
      -   ReqHeader      X-Real-IP: 127.0.0.1
      -   ReqHeader      Ssl-Offloaded: 1
      -   ReqHeader      User-Agent: curl/7.58.0
      -   ReqHeader      Accept: */*
      -   ReqHeader      X-Varnish: 327699
      -   ReqHeader      grace: none
      -   ReqHeader      Accept-Encoding: gzip
      -   ReqHeader      X-Varnish: 229386
      -   ReqUnset       X-Forwarded-For: 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97
      -   ReqHeader      X-Forwarded-For: 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237
      -   VCL_call       RECV
      -   ReqUnset       grace: none
      -   ReqHeader      grace: none
      -   ReqURL         /
      -   ReqUnset       Accept-Encoding: gzip
      -   ReqHeader      Accept-Encoding: gzip
      -   VCL_return     hash
      -   VCL_call       HASH
      -   VCL_return     lookup
      -   Timestamp      Waitinglist: 1607433770.318969 360.006421 360.006421
      -   VCL_call       MISS
      -   VCL_return     fetch
      -   Link           bereq 163849 fetch
      -   Timestamp      Fetch: 1607433890.320555 480.008007 120.001586
      -   RespProtocol   HTTP/1.1
      -   RespStatus     504
      -   RespReason     Gateway Time-out
      -   RespHeader     Server: nginx
      -   RespHeader     Date: Tue, 08 Dec 2020 13:24:50 GMT
      -   RespHeader     Content-Type: text/html
      -   RespHeader     Content-Encoding: gzip
      -   RespHeader     Vary: Accept-Encoding
      -   RespHeader     X-Varnish: 360454
      -   RespHeader     Age: 0
      -   RespHeader     Via: 1.1 varnish (Varnish/5.2)
      -   VCL_call       DELIVER
      -   RespUnset      Age: 0
      -   RespHeader     Pragma: no-cache
      -   RespHeader     Expires: -1
      -   RespHeader     Cache-Control: no-store, no-cache, must-revalidate, max-age=0
      -   RespUnset      Server: nginx
      -   RespUnset      X-Varnish: 360454
      -   RespUnset      Via: 1.1 varnish (Varnish/5.2)
      -   VCL_return     deliver
      -   Timestamp      Process: 1607433890.320577 480.008029 0.000022
      -   RespHeader     Content-Length: 114
      -   RespHeader     Connection: keep-alive
      -   Timestamp      Resp: 1607433890.320603 480.008055 0.000026
      -   ReqAcct        567 0 567 281 114 395
      -   End            
      
      *   << BeReq    >> 557089    
      -   Begin          bereq 425994 fetch
      -   Timestamp      Start: 1607433830.286289 0.000000 0.000000
      -   BereqMethod    GET
      -   BereqURL       /
      -   BereqProtocol  HTTP/1.1
      -   BereqHeader    X-Forwarded-Proto: http
      -   BereqHeader    X-Forwarded-Port: 80
      -   BereqHeader    Host: 172.31.46.83
      -   BereqHeader    X-Amzn-Trace-Id: Self=1-5fcf7c4a-75954cec540fbb5c49ccfbf7;Root=1-5fcf79b6-3217f91a2ff5c5423c48f782
      -   BereqHeader    Ssl-Offloaded: http
      -   BereqHeader    X-Forwarded-Host: 172.31.46.83
      -   BereqHeader    X-Real-IP: 127.0.0.1
      -   BereqHeader    Ssl-Offloaded: 1
      -   BereqHeader    User-Agent: ELB-HealthChecker/2.0
      -   BereqHeader    X-Varnish: 32774
      -   BereqHeader    X-Varnish: 327681
      -   BereqHeader    X-Varnish: 262152
      -   BereqHeader    X-Forwarded-For: 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.32.16
      -   BereqHeader    grace: none
      -   BereqHeader    Accept-Encoding: gzip
      -   BereqHeader    X-Varnish: 557089
      -   VCL_call       BACKEND_FETCH
      -   VCL_return     fetch
      -   BackendOpen    28 boot.default 127.0.0.1 8080 127.0.0.1 50488
      -   BackendStart   127.0.0.1 8080
      -   Timestamp      Bereq: 1607433830.286345 0.000056 0.000056
      -   Timestamp      Beresp: 1607433950.298933 120.012644 120.012588
      -   BerespProtocol HTTP/1.1
      -   BerespStatus   504
      -   BerespReason   Gateway Time-out
      -   BerespHeader   Server: nginx
      -   BerespHeader   Date: Tue, 08 Dec 2020 13:25:50 GMT
      -   BerespHeader   Content-Type: text/html
      -   BerespHeader   Content-Length: 132
      -   BerespHeader   Connection: keep-alive
      -   TTL            RFC -1 10 0 1607433950 1607433950 1607433950 0 0
      -   VCL_call       BACKEND_RESPONSE
      -   TTL            VCL -1 259200 0 1607433950
      -   TTL            VCL 0 259200 0 1607433950
      -   VCL_return     deliver
      -   BerespUnset    Content-Length: 132
      -   BerespHeader   Content-Encoding: gzip
      -   BerespHeader   Vary: Accept-Encoding
      -   Storage        malloc Transient
      -   ObjProtocol    HTTP/1.1
      -   ObjStatus      504
      -   ObjReason      Gateway Time-out
      -   ObjHeader      Server: nginx
      -   ObjHeader      Date: Tue, 08 Dec 2020 13:25:50 GMT
      -   ObjHeader      Content-Type: text/html
      -   ObjHeader      Content-Encoding: gzip
      -   ObjHeader      Vary: Accept-Encoding
      -   Fetch_Body     3 length -
      -   Gzip           G F E 132 114 80 832 842
      -   BackendReuse   28 boot.default
      -   Timestamp      BerespBody: 1607433950.299206 120.012917 0.000273
      -   Length         114
      -   BereqAcct      575 0 575 155 0 155
      -   End            
      
      *   << Request  >> 425994    
      -   Begin          req 425993 rxreq
      -   Timestamp      Start: 1607433290.239443 0.000000 0.000000
      -   Timestamp      Req: 1607433290.239443 0.000000 0.000000
      -   ReqStart       172.31.32.16 25426
      -   ReqMethod      GET
      -   ReqURL         /
      -   ReqProtocol    HTTP/1.1
      -   ReqHeader      X-Forwarded-For: 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97
      -   ReqHeader      X-Forwarded-Proto: http
      -   ReqHeader      X-Forwarded-Port: 80
      -   ReqHeader      Host: 172.31.46.83
      -   ReqHeader      X-Amzn-Trace-Id: Self=1-5fcf7c4a-75954cec540fbb5c49ccfbf7;Root=1-5fcf79b6-3217f91a2ff5c5423c48f782
      -   ReqHeader      Ssl-Offloaded: http
      -   ReqHeader      X-Forwarded-Host: 172.31.46.83
      -   ReqHeader      X-Real-IP: 127.0.0.1
      -   ReqHeader      Ssl-Offloaded: 1
      -   ReqHeader      User-Agent: ELB-HealthChecker/2.0
      -   ReqHeader      X-Varnish: 32774
      -   ReqHeader      X-Varnish: 327681
      -   ReqHeader      grace: none
      -   ReqHeader      Accept-Encoding: gzip
      -   ReqHeader      X-Varnish: 262152
      -   ReqUnset       X-Forwarded-For: 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97
      -   ReqHeader      X-Forwarded-For: 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.18.237, 127.0.0.1, 3.121.220.97, 172.31.32.16
      -   VCL_call       RECV
      -   ReqUnset       grace: none
      -   ReqHeader      grace: none
      -   ReqURL         /
      -   ReqUnset       Accept-Encoding: gzip
      -   ReqHeader      Accept-Encoding: gzip
      -   VCL_return     hash
      -   VCL_call       HASH
      -   VCL_return     lookup
      -   Timestamp      Waitinglist: 1607433830.286193 540.046750 540.046750
      -   VCL_call       MISS
      -   VCL_return     fetch
      -   Link           bereq 557089 fetch
      -   Timestamp      Fetch: 1607433950.299289 660.059846 120.013096
      -   RespProtocol   HTTP/1.1
      -   RespStatus     504
      -   RespReason     Gateway Time-out
      -   RespHeader     Server: nginx
      -   RespHeader     Date: Tue, 08 Dec 2020 13:25:50 GMT
      -   RespHeader     Content-Type: text/html
      -   RespHeader     Content-Encoding: gzip
      -   RespHeader     Vary: Accept-Encoding
      -   RespHeader     X-Varnish: 425994
      -   RespHeader     Age: 0
      -   RespHeader     Via: 1.1 varnish (Varnish/5.2)
      -   VCL_call       DELIVER
      -   RespUnset      Age: 0
      -   RespHeader     Pragma: no-cache
      -   RespHeader     Expires: -1
      -   RespHeader     Cache-Control: no-store, no-cache, must-revalidate, max-age=0
      -   RespUnset      Server: nginx
      -   RespUnset      X-Varnish: 425994
      -   RespUnset      Via: 1.1 varnish (Varnish/5.2)
      -   VCL_return     deliver
      -   Timestamp      Process: 1607433950.299316 660.059873 0.000027
      -   RespHeader     Content-Length: 114
      -   RespHeader     Connection: keep-alive
      -   Timestamp      Resp: 1607433950.299341 660.059898 0.000025
      -   ReqAcct        542 0 542 281 114 395
      -   End 
      
             
      

      nginx 日志 ec2 清漆

      2020/12/08 13:25:50 [error] 21478#21478: *10 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://18.159.192.218:80/", host: "111-1249061354.eu-central-1.elb.amazonaws.com"
      2020/12/08 13:26:50 [error] 21478#21478: *8 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://18.159.192.218:80/", host: "172.31.46.83"
      2020/12/08 13:26:50 [error] 21478#21478: *10 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://18.192.113.24:80/", host: "111-1249061354.eu-central-1.elb.amazonaws.com"
      

      我做错了什么?请帮忙看看

      【讨论】:

        猜你喜欢
        • 2017-03-05
        • 2018-08-25
        • 2017-03-06
        • 1970-01-01
        • 1970-01-01
        • 2015-04-17
        • 2018-08-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多