skip to Main Content

I have problem with "Error 503 Service Unavailable" Error is showing after 24 hours. I am using varnish-6.5.1 for full page cache with newest nginx serwer. Magento version is 2.3.4. I am using SSL certificate and Magento is in developer mode.
My varnish configuration look like this:

sudo systemctl edit --full  varnish


[Unit]
Description=Varnish Cache, a high-performance HTTP accelerator
After=network-online.target nss-lookup.target

[Service]
Type=forking
KillMode=process

# Maximum number of open files (for ulimit -n)
LimitNOFILE=131072

# Locked shared memory - should suffice to lock the shared memory log
# (varnishd -l argument)
# Default log size is 80MB vsl + 1M vsm + header -> 82MB
# unit is bytes
LimitMEMLOCK=85983232

# Enable this to avoid "fork failed" on reload.
TasksMax=infinity

# Maximum size of the corefile.
LimitCORE=infinity

ExecStart=/usr/sbin/varnishd 
          -a :6081 
          -a 127.0.0.1:8443,PROXY 
          -p feature=+http2 
          -f /etc/varnish/default.vcl 
          -s malloc,3G 
          -p pipe_timeout=600 
          -p http_resp_hdr_len=65536 
          -p http_resp_size=98304
ExecReload=/usr/sbin/varnishreload

[Install]
WantedBy=multi-user.target

My nginx configuration looks like this:

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

server {
    listen 80;
    listen [::]:80;
    server_name 127.0.0.0.1 mysite.pl www.mysite.pl;
    return 301 https://mysite.pl$request_uri;
}

server {

  listen 443 ssl http2;
  server_name 185.243.53.221 127.0.0.1 mysite.pl www.mysite.pl;

  access_log   /var/log/nginx/www.mysite.pl.log;
  error_log    /var/log/nginx/www.mysite.pl-error.log;

  ssl_certificate_key /etc/nginx/ssl/www.mysite.pl.key;
  ssl_certificate     /etc/nginx/ssl/www.mysite.pl.pem;

  ssl_protocols TLSv1.2;
  ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SH$

  ssl_prefer_server_ciphers off;

  add_header X-Frame-Options "SAMEORIGIN";
  add_header Strict-Transport-Security max-age=31536000;
    keepalive_timeout 600s;
    location / {
        proxy_pass http://127.0.0.1:6081;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Port 443;
        proxy_set_header Host $host;
    }

}

server {
    listen 8080;
    server_name 127.0.0.1 mysite.pl www.mysite.pl;
    set $MAGE_ROOT /var/www/magento2;
    include /var/www/magento2/nginx.conf.sample;
}

How can I check what is causing the error?

2

Answers


  1. Chosen as BEST ANSWER

    I used command

    sudo varnishlog -d -q "vxid == 557088"
    

    And error is "Too many restarts" Below I have paste full log

    *   << Request  >> 557088    
    -   Begin          req 557087 restart
    -   Timestamp      Start: 1603710828.024454 0.000236 0.000000
    -   ReqStart       127.0.0.1 51688 a0
    -   ReqMethod      GET
    -   ReqURL         /
    -   ReqProtocol    HTTP/1.0
    -   ReqHeader      X-Real-IP: 83.6.151.188
    -   ReqHeader      X-Forwarded-Proto: https
    -   ReqHeader      X-Forwarded-Port: 443
    -   ReqHeader      Host: wymienolej.pl
    -   ReqHeader      X-Forwarded-Host: wymienolej.pl
    -   ReqHeader      Connection: close
    -   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/86.0.4240.75 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      sec-fetch-site: none
    -   ReqHeader      sec-fetch-mode: navigate
    -   ReqHeader      sec-fetch-user: ?1
    -   ReqHeader      sec-fetch-dest: document
    -   ReqHeader      accept-language: pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7
    -   ReqHeader      cookie: AMCVS_8F99160E571FC0427F000101%40AdobeOrg=1; s_cc=true
    -   ReqHeader      X-Forwarded-For: 83.6.151.188, 127.0.0.1
    -   ReqHeader      grace: none
    -   ReqHeader      Accept-Encoding: gzip
    -   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
    -   Hit            557074 -3106.505552 259200.000000 0.000000
    -   VCL_call       HIT
    -   VCL_return     restart
    -   VCL_Error      Too many restarts
    -   RespProtocol   HTTP/1.1
    -   RespStatus     503
    -   RespReason     Service Unavailable
    -   RespHeader     Date: Mon, 26 Oct 2020 11:13:48 GMT
    -   RespHeader     Server: Varnish
    -   RespHeader     X-Varnish: 557088
    -   VCL_call       SYNTH
    -   RespHeader     Content-Type: text/html; charset=utf-8
    -   RespHeader     Retry-After: 5
    -   VCL_return     deliver
    -   Timestamp      Process: 1603710828.024479 0.000262 0.000025
    -   RespHeader     Content-Length: 280
    -   Storage        malloc Transient
    -   Filters        
    -   RespHeader     Connection: close
    -   Timestamp      Resp: 1603710828.024534 0.000317 0.000055
    -   ReqAcct        763 0 763 205 280 485
    -   End            
    

  2. I added this code to my default.vcl file:

    sudo nano /etc/varnish/default.vcl
    
    sub vcl_recv {
    
        if (req.restarts > 0) {
            set req.hash_always_miss = true;
        }
    
        if (req.method == "PURGE") {
    ...
    

    It seems to work, no 503 error for now.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search