With the recent release of Magento Commerce 2.4.1, the platform adopted several new security measures, performance capabilities, B2B tools, and fixed dozens of known issues and vulnerabilities that were apparent in previous versions. Several new features were added to make the shopping experience better for customers while making it easier for retailers to manage their online stores and protect them from hackers. Origin Cloaking, one of the latest technologies incorporated into this new Magento release, is one of the most outstanding features for merchants who want the best protection for their websites.
How Origin Cloaking Works
When Origin Cloaking is enabled, it hides the IP of all of your origin servers in order to protect them from direct access. The Origin Cloaking mechanism connects to the origin IP in such a way that Fastly is designated as the only source that can allow valid traffic through. In other words, all traffic to your Cloud infrastructure must go through the Fastly CDN (Content Delivery Network) or another established secure channel. Any traffic that tries to directly access your origin servers will effectively be blocked.
How to Bypass Fastly Cache
If you have traffic that doesn’t require caching, it’s easy to configure the Fastly service in a way that will allow certain requests to bypass the caching process. For example, if you need to troubleshoot issues with your site that you suspect may have to do with caching, you can follow these steps to get through Fastly based on URL or IP address:
- Log in to your Magento Admin account.
- Click on Stores, then go to Settings > Configuration > Advanced > System.
- Click on Full Page Cache, go to Fastly Configuration, and hit Custom VCL Snippets.
- Click Create Custom Snippet.
- Add the VCL snippet values:
- Name: bypass_fastly
- Type: recv
- Priority: 5
- VCL snippet content for a specific IP address:
- if (client.ip == “<Your IPv4 IP address>” || client.ip == “<Your IPv6 IP address>”) { return(pass);}
- VCL snippet content for a specific URL pattern:
- if (req.url ~ “/media/feeds/GoogleShoppingHiVisNew.xml”) { return (pass);}
- Click Create.
- Once the page reloads, click Upload VCL to Fastly (in the Fastly Configuration section).
- After the upload is finished, refresh the cache by following the instructions given at the top of the page.
How to Modify Custom VCL Snippet
If you need to update any of the custom snippets you create, you can easily modify them by going through a similar process:
- Log in to your Magento Admin account.
- Click Stores, go to Settings, and then Configuration > Advanced > System.
- Expand Full Page Cache > Fastly Configuration > Custom VCL Snippets.
- In the Action column, click on the settings icon next to the snippet to edit it.
- After the page reloads, click Upload VCL to Fastly in the Fastly Configuration section.
- After the upload completes, refresh the cache according to the notification at the top of the page.
For more information about Origin Cloaking or the other features of Magento 2.4.1, you can review the release notes here!