Report this

What is the reason for this report?

How to Rewrite home page url in Varnish

Posted on July 10, 2020

Hi, I have configured varnish with Magento 2.3.x and its working fine with the sub folders and pages. However, when I open domain.com in the browser it gives me 503 error. But domain.com/index.php/ works fine.

What I want to achieve here is I want to remove /index.php/ and let the user view from domain.com/ instead.

Now, this works absolutely fine in Nginx, I have rules in nginx and it works fine, but when I configure it with varnish i get this issue.

My nginx & varnish (default.vcl) is given below. I believe varnish is somehow rejecting domain.com.

nginx.conf: https://pastebin.com/raw/tQ9wAmEP

default.vcl: https://pastebin.com/raw/JmE5fncy

I have already made suggested changes by Magento docs i.e.

-p http_resp_hdr_len=65536 
-p http_resp_size=98304 
-p workspace_backend=98304


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.

Your issue might be with an incorrect Varnish configuration, or it could be a problem with the Nginx configuration and how it interacts with Varnish. You mentioned that you have made the suggested changes by Magento docs, but still experiencing issues.

In your Varnish default.vcl, it’s important to properly set backend settings pointing to your Nginix and ensure that req.http.host is correctly defined.

Consider modifying your Varnish configuration and take care of the following points:

- Make sure your backend default points Nginx correctly. Confirm the health status of your backend server after modifying the Varnish settings with the command: varnishadm debug.health-
Ensure that the req.http.host is correctly defined for your domain.

If the problem persists after making these changes, please refer to the DigitalOcean Docs at How To Configure Varnish Cache and How To Configure Nginx as a Web Server and Reverse Proxy for Apache on One Ubuntu 20.04 Server. These articles provide a detailed overview of configuring Varnish with Nginx. If all else fails, you may consider seeking further assistance from the Magento community forums.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.