Follow this guide to host your Ferndesk help center at a custom subfolder (like yourdomain.com/help) using Cloudflare Workers as a reverse proxy.

This takes approximately 10 minutes to do and requires little technical knowledge. We've written it to be as easy to follow as possible.

Getting stuck? Contact [email protected] and we'll help you complete your setup.

Prerequisites

  • A Ferndesk workspace with admin access

  • A domain you own (already pointed to Cloudflare)

  • Basic familiarity with Cloudflare's dashboard

Cloudflare's free plan allows 100,000 Worker requests per day. For production help centers with high traffic, consider upgrading to a paid plan with pay-per-use billing.

Step 1: Set up the custom subfolder in Ferndesk

First, configure your Ferndesk help center to use a custom subfolder path.

  1. Log in to your Ferndesk workspace and navigate to Customize in the left sidebar.

  2. Click Custom domain

  3. Select the Custom sub-folder option (marked as Recommended).

    Custom domain configuration screen with Custom sub-folder option selected and recommended label visible
  1. Enter your domain in the Domain field (e.g., yourdomain.com).

  2. Enter your desired subfolder path in the Subdirectory field (e.g., /help or /docs).

  3. Click Configure sub-folder.

Once configured, Ferndesk will generate the necessary DNS records and endpoint information. Note these details—you'll use them when setting up the reverse proxy.

Step 2: Create a Cloudflare Worker

Now create a new Cloudflare Worker that will act as a reverse proxy.

  1. Log in to your Cloudflare dashboard.

  2. Under BUILD Compute & AI, navigate to Workers & Pages from the left sidebar .

    Cloudflare dashboard showing Workers & Pages menu option highlighted in the left sidebar under BUILD section
  3. Click Create application in the top right corner.

    Cloudflare Workers & Pages dashboard with Create application button visible in the top right
  4. Under Start with Hello World!, click Get started.

  5. Name your Worker something descriptive like ferndesk-reverse-proxy, then click Deploy.

Step 3: Configure the worker routes

Set up the routing rule that directs traffic from your custom subfolder to the Cloudflare Worker.

  1. In the Worker settings, navigate to the Settings tab.

  2. Scroll to Domains & Routes and click Add.

  3. A modal window will open. Select the Route option.

    Modal dialog for configuring domains and routes with Route option highlighted
  4. In the Zone dropdown, select your domain (e.g., yourdomain.com).

  5. In the Route field, enter the pattern for your subfolder path. Use *yourdomain.com/help* to capture all requests to the /help path and its subpaths.

  6. Leave Failure mode set to Fail closed (block) for security.

  7. Click Add route.

    Route configuration modal showing zone set to yourdomain.com and route pattern set to *yourdomain.com/help* with failure mode options

IMPORTANT: You need to add a separate route for the ferndesk assets directory _ferndesk. Follow the steps below to complete your setup.

Step 3b: Adding the _ferndesk route

  1. Scroll to Domains & Routes and click Add.

  2. A modal window will open. Select the Route option.

    Modal dialog for configuring domains and routes with Route option highlighted
  3. In the Zone dropdown, select your domain (e.g., yourdomain.com).

  4. In the Route field, enter the pattern for your subfolder path. Use *yourdomain.com/_ferndesk* to capture all requests to the /_ferndesk path and its subpaths.

  5. Leave Failure mode set to Fail closed (block) for security.

  6. Click Add route.

Step 4: Edit the Worker code

Now update the Worker code to handle the reverse proxy logic. The Worker will intercept requests to your subfolder and forward them to Ferndesk.

  1. Click Edit code (or access the code editor from the Worker dashboard).

  2. Replace the entire worker.js code with the reverse proxy script below.

    // ONLY edit these
    
    const HELP_HOST = 'your-slug.hc.ferndesk.com'; // your Ferndesk help center host copied from your dashboard
    const PROXY_PREFIX = '/help'; // the path you want your help center to live on
    
    addEventListener('fetch', (event) => {
    	event.respondWith(handleRequest(event.request));
    });
    
    async function handleRequest(request) {
    	const originalUrl = new URL(request.url);
    
    
    	if (originalUrl.pathname.endsWith('/') && originalUrl.pathname !== '/') {
    		originalUrl.pathname = originalUrl.pathname.slice(0, -1);
    		return Response.redirect(originalUrl.toString(), 301);
    	}
    
    
    	if (
    		originalUrl.pathname !== PROXY_PREFIX &&
    		!originalUrl.pathname.startsWith(`${PROXY_PREFIX}/`) &&
    		!originalUrl.pathname.startsWith('/_ferndesk/')
    	) {
    		return fetch(request);
    	}
    
    	// Build the upstream request with the prefix removed
    	const upstreamUrl = new URL(originalUrl.toString());
    	upstreamUrl.hostname = HELP_HOST;
    
    	if (upstreamUrl.pathname === PROXY_PREFIX) {
    		upstreamUrl.pathname = '/';
    	} else if (upstreamUrl.pathname.startsWith(`${PROXY_PREFIX}/`)) {
    		upstreamUrl.pathname = upstreamUrl.pathname.slice(PROXY_PREFIX.length) || '/';
    	}
    
    	const proxyRequest = new Request(upstreamUrl.toString(), request);
    
    	// CRITICAL: Needed to resolve requests correctly
    	proxyRequest.headers.set('X-Ferndesk-Base-Path', PROXY_PREFIX);
    	proxyRequest.headers.set('X-Forwarded-Host', originalUrl.host);
    	proxyRequest.headers.set('X-Ferndesk-Original-Host', originalUrl.host);
    
    
    	return fetch(proxyRequest);
    }

    Replace HELP_HOST with the actual Ferndesk domain provided when you configured your custom subfolder. Replace PROXY_PREFIX if you're using a different subfolder path (e.g., /docs instead of /help).

  3. Click Deploy to publish your changes.

Step 5: Verify the setup

Test that your help center is now accessible at your custom subfolder path.

  1. Open a new browser tab and navigate to https://yourdomain.com/help.

  2. You should see your Ferndesk help center loaded with your branding.

  3. Test a few pages by clicking links to ensure navigation works correctly.

If your help center loads successfully and displays your content, the reverse proxy is working correctly! Your customers can now access your help center at your custom domain.

Something went wrong? Contact us at [email protected] and we'll help you complete your setup.

Troubleshooting

Issue

Cause

Solution

404 Not Found error when visiting the URL

Route is not configured correctly or the Worker is not deployed

Verify the route pattern matches your domain and subfolder path exactly. Check that the Worker is deployed and active in the Domains & Routes section.

Blank page or broken styling

Ferndesk domain in Worker code is incorrect

Double-check the ferndesk_host variable in your Worker code matches the domain provided by Ferndesk. Deploy the corrected code.

CSS and images not loading

Relative URLs in the Ferndesk response aren't being rewritten

You may need to add response header rewriting to handle relative assets. Contact Ferndesk support for advanced proxy configuration.

Worker requests limited to 100,000/day

Cloudflare free plan rate limit reached

Upgrade your Cloudflare plan to pay-per-use billing for unlimited requests beyond the free tier.

Was this helpful?