We just released an edge proxy implemented as a Cloudflare worker script and published to npm as Cloudflare-edge-proxy
. It enables a bunch of features including a/b/n testing, canary releasing, gatekeeping, and SEO a/b/n testing. Full docs are on Github: GitHub - DigitalOptimizationGroup/cloudflare-edge-proxy: A Cloudflare worker script used to enable a/b testing, canary releasing, gatekeeping, and SEO a/b/n testing.
Install with: npm install Cloudflare-edge-proxy
A quick example of using it for an a/b/c test
The worker script:
import CloudflareEdgeProxy from "Cloudflare-edge-proxy";
const config = {
defaultBackend: "https://a.com",
abtest: true,
origins: [
{ url: "https://a.com" },
{ url: "https://b.com" },
{ url: "https://c.com" }
],
salt: "test-abc-123"
};
const proxy = CloudflareEdgeProxy(config);
addEventListener("fetch", event => {
event.respondWith(proxy(event));
});
And another example for canary releasing
Canary releasing can be used to gradually shift traffic from one backend to another. It should ONLY be used with two backends, (unlike a/b/n testing), so that users do not get reassigned as the traffic percentage is increased. An example config is shown below. To assure consistent assignment, for visitors, the weight parameter should only be increased.
import CloudflareEdgeProxy from "Cloudflare-edge-proxy";
const config = {
canary: true,
weight: 50, // 0-100
canaryBackend: "https://canary-backend.com",
defaultBackend: "https://default-backend.com",
salt: "canary-abc-123"
};
const proxy = CloudflareEdgeProxy(config);
addEventListener("fetch", event => {
event.respondWith(proxy(event));
});
If this is useful to anyone of if there are any questions, please let us know!