Skip to main content

How to Set Up a Reverse Proxy to PartnerPage with Cloudflare Workers

Use Cloudflare Workers to customize your directory URL to seem as if it's part of your site, such as yourdomain.com/experts

R
Written by Roberto Carozza
Updated over a week ago

You can serve your PartnerPage-hosted directory under your own domain (e.g. yourdomain.com/partner-directory/) by using Cloudflare Workers. This keeps users on your domain while loading content from your PartnerPage instance.

✅ Requirements

  • Your domain is using Cloudflare DNS

  • You have Cloudflare Workers enabled (included in most paid plans)

  • You want to serve a directory under a path like /partner-directory/ or /integrations-directory/

  • Your know your PartnerPage base URL (e.g. https://<your-id>.directory.sites.partnerpage.io or <yourcompany>.partnerpage.io)

1: Add a Cloudflare Worker

  1. Select the domain you’d like to use

  2. Navigate to Workers & Pages > Workers

  3. Click “Create Worker”

This will open the Cloudflare Worker editor.

Step 2: Add the PartnerPage Proxy Script

Paste the following script into the Worker editor:

addEventListener("fetch", event => {
const requestURI = new URL(event.request.url);

if (
requestURI.hostname === "yourdomain.com" && // replace with your actual domain
(requestURI.pathname.startsWith("/partner-directory/") ||
requestURI.pathname.startsWith("/integrations-directory/"))
) {
event.respondWith(rewriteProxyURL(event.request));
}
});

async function rewriteProxyURL(request) {
const originalURI = new URL(request.url);
const newURI = new URL(request.url);

newURI.protocol = "https:";
newURI.hostname = "yourname.partnerpage.io"; // replace with your PartnerPage subdomain
newURI.pathname = originalURI.pathname;

const clientIP = request.headers.get("cf-connecting-ip");

const headers = new Headers(request.headers);
headers.set("PartnerPage-Client-IP", clientIP);
headers.set("PartnerPage-Reverse-Proxy", "true");

return fetch(newURI.toString(), {
method: request.method,
headers: headers,
body: request.body,
redirect: "follow"
});
}

Configure the script for your setup:

Replace the following values:

  1. Line 4: Replace "yourdomain.com" with your actual domain

  2. Line 5-6: Update the path(s) to match your desired directory URL. You can:

    • Keep one path and remove the other if you only need one directory

    • Add additional paths using the same pattern

    • Customize the path names (e.g., /experts/, /partners/, /marketplace/)

  3. Line 17: Replace "yourname.partnerpage.io" with your PartnerPage subdomain (found in your PartnerPage admin or onboarding instructions)

Important: The full path (including /partner-directory/) will be forwarded to your PartnerPage instance. For example:

  • Request: yourdomain.com/partner-directory/partner-123

  • Proxied to: yourname.partnerpage.io/partner-directory/partner-123

3: Assign a Route to the Worker

Once your script is saved:

  1. Go to the “Triggers” tab in your Worker

  2. Under the "Routes" section, click "Add route"

  3. Enter your route pattern that matches the path you want to proxy:

    yourdomain.com/partner-directory/*

  4. Select your domain zone from the dropdown

  5. Click "Save"

Note: If you're proxying multiple paths (e.g., both /partner-directory/ and /integrations-directory/), add a separate route for each:

  • yourdomain.com/partner-directory/*

  • yourdomain.com/integrations-directory/*

This route tells Cloudflare to invoke your Worker whenever someone visits that path.

4. Review your configuration

To successfully proxy your PartnerPage directory using Cloudflare Workers, make sure you have:

  • ✅ A Cloudflare Worker that:

    • Matches your desired path (e.g. /partner-directory/ or /integrations-directory/)

    • Forwards the complete path of the request to your PartnerPage subdomain

    • Sets the required headers below

  • ✅ One or more route like yourdomain.com/partner-directory/* bound to the Worker in the Triggers tab

  • ✅ The following required headers included in the request:

    • PartnerPage-Reverse-Proxy: true

    • PartnerPage-Client-IP: <visitor IP from cf-connecting-ip>

These headers are required for PartnerPage to accept and respond to proxy traffic properly. Without them, requests may be rejected or fail to load.

Once configured, your PartnerPage content will appear seamlessly under your domain with full functionality.

Troubleshooting

404 errors when visiting your proxied URL:

  • Verify your route pattern matches exactly (including the /* wildcard)

  • Check that your PartnerPage subdomain is correct

  • Ensure the path in your Worker script matches the route you configured

Content not loading or styling broken:

  • Confirm the required headers (PartnerPage-Reverse-Proxy and PartnerPage-Client-IP) are set in the script

  • Check your browser's developer console for any blocked resources

Redirect loops:

  • Make sure your PartnerPage instance doesn't have conflicting redirect rules

  • Verify your Worker's hostname check matches your actual domain

Need help? Reach out to PartnerPage support anytime.

Did this answer your question?