Skip to content

Instantly share code, notes, and snippets.

@erikhansen
Last active June 1, 2026 19:18
Show Gist options
  • Select an option

  • Save erikhansen/2e35fc65c72259aad2b15249cf079fc9 to your computer and use it in GitHub Desktop.

Select an option

Save erikhansen/2e35fc65c72259aad2b15249cf079fc9 to your computer and use it in GitHub Desktop.
Adobe Commerce Cloud w/ Cloudfare VCL configuration

Overview

NOTE: I just tested this (2026-06-01) on an Adobe Commerce Cloud site and could not get it to work, despite a couple of developers managing other sites attesting that it did work for them. So YMMV.

We (Kraken Commerce) recommend using Cloudflare in front of Adobe Commerce Cloud environments, as Cloudflare provides excellent bot-fighting and performance tools. However a small change is needed in the Magento VCL to pass the user's IP from Cloudflare>Fastly/Varnish>Nginx so that user's IPs are stored in the access logs correct.

Steps:

  1. Login to the Magento admin and go to STORES > Configuration > ADVANCED > System and expand the Full Page Cache > Fastly Configuration > Custom VCL Snippets section.
  2. Click the "Create" button and add this information:
    1. Name: forward_client_ip (or whatever you want to call it)
    2. Type: recv
    3. Priority: 100
    4. VCL:
# Ensure the user's IP address is forwarded through to Nginx so that the access logs contain the correct IP
if (req.http.cf-connecting-ip) {
    set req.http.X-Client-IP = req.http.cf-connecting-ip;
}
  1. Click the "Upload VCL to Fastly" button

Testing

  1. Before making the change, load url like https://example.com/customer/account/login/?testing=123 in your browser
  2. In New Relic, go to Logs and filter by `filePath:"/var/log/platform/*/access.log" message:"testing=123"
  3. You'll see the IP listed is not your IP
  4. Make the change above
  5. The IP listed should now be your IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment