LogoLogo
MerchantsHelpSign in
  • Overview
    • Countries & Currencies
    • Glopal Solutions Portfolio
  • Getting started
    • Shopify
      • Glopal Duty & Tax for Shopify
      • Shopify Collaborator Access
    • BigCommerce
    • Magento (Adobe Commerce)
      • Magento 1
      • Magento 2
        • Magento Activation
        • Magento Configuration
        • Magento Database Model
    • Visualsoft
    • PrestaShop
  • Marketing Solutions
    • Acquisition channels
      • Integrate Google Ads
      • Integrate Facebook Ads
    • Feed localization
      • Read domestic items
      • Localize the items
      • Upload the localized items
    • Features / Customization
      • Google Shopping countries coverage
      • Filters
      • Free listings
      • Comparison Shopping Services (CSS)
    • Google Ads
      • Conversion tracking
      • Standard accounts structure
      • Launching and monitoring Google Ads campaigns
    • Facebook
      • Facebook & Instagram Shops
      • Catalog Based Campaigns
      • Conversion and Brand awareness campaigns
      • Facebook conversion tracking
    • Email marketing
  • Localization
    • Site localization
      • Content localization
      • Price localization
      • Site search
      • Checkout
      • User account
    • Site discovery
      • Domains and Routing
      • Search engine optimization
      • Geo-localization
      • Country selector
    • Content distribution
      • Site security
      • Domains (DNS)
      • Traffic Splitting
        • Akamai
        • Cloudflare
        • Nginx
        • Microsoft IIS
        • AWS CloudFront
        • Magento Cloud
      • Third-party CDN
        • Cloudflare
      • Site speed
    • Integrations
      • CSS customizations
      • JavaScript customizations
      • Server-side customizations
      • Exclude from localization
      • Integration examples
        • Hiding Products
        • Newsletter Signup
        • Custom Price Logic
  • Checkout
    • Localized checkout
      • Overview
      • Styling
      • Integration
        • Callback Functions
        • Confirmation Page
        • Checkout Analytics
        • Allowlisting Glopal IPs
      • Price localization
    • Order processing
      • Order creation
        • Plug & Play integration
        • Order API
        • Event webhook
        • Custom Integration
      • Cancellation & refund
      • Returns
      • Buyer's communication
      • Customer account
    • Financials
      • EU VAT
  • DUTY & TAXES
    • Product Classification
    • Duty & Tax Calculation
      • Product Pricing
      • Supported Countries
    • Compliance Checks
      • Prohibited Goods
      • Denied Party Screening
  • SHIPPING
    • Order Creation
    • Label Generation
    • Manifest
    • Tracking
  • Translations
    • Translation Editor
  • MERCHANT ACCOUNT
    • Dashboards
      • SEO dashboard
  • What's New
    • Release Notes
Powered by GitBook
On this page
  • Setup
  • Create a Worker
  • Setup Route
  1. Localization
  2. Content distribution
  3. Traffic Splitting

Cloudflare

Setting up Traffic Splitting with Cloudflare

PreviousAkamaiNextNginx

Last updated 3 months ago

Setup

To use Traffic Splitting with Cloudflare you will need to deploy a new Cloudflare Worker. This Worker will manage and direct traffic flow between Glopal Proxy and your service Origin.

Before considering using Cloudflare Workers to configure traffic splitting, ensure that Cloudflare CDN is enabled. You can verify this by checking that the "orange cloud" icon is active for your target site record under DNS settings.

Create a Worker

  1. Log in to the Cloudflare dashboard and select your account.

  2. Select Workers & Pages > Create application.

  3. Select Create Worker > Deploy.

Navigate to the newly created worker and click the "Edit Code" button. This will open the editor where you can write and deploy your Worker script. In the editor, you'll find a pre-filled script; delete it.

  1. Copy the following script and Paste it into the Workers editor.

  2. Make sure to replace GLOPAL_HOSTNAME placeholder with the value you receive from Glopal (for example store-1234.app.glopalstore.com) and that PATTERN is a regular expression describing you want to delegate to Glopal.

app.js
const GLOPAL_BACKEND_HOSTNAME = '';
const GLOPAL_PATHNAMES_REGEXP = new RegExp('^/()($|[:/?])');

addEventListener("fetch", (event) => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
  const url = new URL(request.url);
  if (!url.pathname.match(GLOPAL_PATHNAMES_REGEXP)) {
    return fetch(request);
  }
  const newReq = new Request(request);
  newReq.headers.set('X-Forwarded-Host', url.hostname);
  url.hostname = GLOPAL_BACKEND_HOSTNAME;
  url.protocol = 'https:';
  return fetch(url.href, newReq);
}

Testing your rule

To ensure the rule works as expected, conduct a series of tests by visiting URLs that should be affected by the rule and confirming that they are rewritten correctly.

Setup Route

Under worker settings, navigate to Triggers > Routes > Add route.

Enter one or more routes that are matching domain and paths that should be delegated to Glopal. Make sure route ends with a * character.

As Worker code is already checking for "in-scope paths", you can setup a simple route like www.store.com/* to run all requests through the Worker. Alternatively you can configure multiple routes for each delegated path, for example www.store.com/de* and www.store.com/fr*.

list of in-scope paths