skip to Main Content

I need assistance with configuring Varnish with Magento 2 and Nginx. I have attempted the configuration, but I’m encountering a persistent 503 backend error.

I have replaced the default.vcl file with my magento2.vcl file, but the error persists. The specific error message I’m receiving is:

[14/Jul/2023:19:18:26 +0200] "HEAD xx.yy:81/ HTTP/1.1" 301 0 "-" "curl/7.81.0"

I would appreciate guidance on resolving this issue.

2

Answers


  1. Could you post your magento.vcl code ?

    A typical installation would be :
    Nginx (ports http 80 and http 443) -> varnish (http 8080) -> magneto (http 8081)
    The error you’re issuing is a 301 redirection, not a 503
    Typically a 503 is saying « varnish can’t pass the request to backend »
    Either your request or your backend is wrong coded (with too short ttls for example)

    If your setup is brand new, it’s probably the second reason that you may confirm with a varnishadm backend.list

    Probably something like « magneto is running on port 8081 and varnish is configured to get content from port 8888 »

    It the 503 are coming from timeouts, you may see timeouts with a varnishlog

    Some useful varnish commands :
    https://www.getpagespeed.com/server-setup/varnish/varnish-4-command-line

    Login or Signup to reply.
  2. Backend health monitoring

    See https://www.varnish-software.com/developers/tutorials/troubleshooting-varnish/#backend-health-monitoring for a tutorial that explains how to monitor backend health in Varnish.

    If the backend probing fails, it’s probably the reason why you’re getting the 503 error.

    Varnishlog

    You could also dig a bit deeper and use the following tutorial https://www.varnish-software.com/developers/tutorials/troubleshooting-varnish/#backend-errors to leverage varnishlog and inspect the log transactions in detail.

    The 301 error in your logs

    It’s interesting to see the log line that includes a HEAD call and receives the 301 redirect.

    The fact that it’s a HEAD call could relate to a health probe from your VCL file that enforces this request method.

    This is not a bad thing. It could actually make it easier to pinpoint the issue. Please share your VCL file, the backend & health probe details might help us figure this out. If the health probe does a HEAD call, we’re one step closer.

    The 301 redirect is actually an interesting one. If it is related to the health checking, it means your health check endpoint enforces a 301 redirect. Since the health probe expects a 200 status code, it will fail and result in the 503 status code.

    One possible solution could be to examine why the 301 redirection happens and fix that.

    Conclusion

    My suggestions are hypothetical and refer to a potential health checking problem.

    Please share your VCL file. This will help us identify the health checking parameters you’re using.

    The tutorials I shared can also help you debug.

    sudo varnishlog -g raw -i Backend_health and sudo varnishlog -g request -q "VCL_call eq 'BACKEND_ERROR'" are the commands that will help you debug backend health and potential backend failure.
    `

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