Cloudflare
Setting up Traffic Splitting with Cloudflare
Last updated
Setting up Traffic Splitting with Cloudflare
Last updated
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.
Log in to the Cloudflare dashboard and select your account.
Select Workers & Pages > Create application.
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.
Copy the following script and Paste it into the Workers editor.
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 list of in-scope paths you want to delegate to Glopal.
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.
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*.