Cloudflare Integration

Cloudflare - GrackerAI Portal

This guide covers multiple Cloudflare integration scenarios for GrackerAI's cybersecurity content marketing platform, including subpath routing and custom domain setup.

Subpath Routing with Cloudflare

To host your GrackerAI portal at a /yoursubpath subpath using Cloudflare, you'll need to create and configure a Cloudflare Worker.

Set up a Cloudflare Worker

Create a Cloudflare Worker by following the Cloudflare Workers getting started guide (opens in a new tab), if you have not already.

Configure routing

  1. Log in to the Cloudflare dashboard and select your account.
  2. Select Workers & Pages.
  3. Select your application.
  4. Select Edit Code.

Add the following script into your Worker's code. See the Cloudflare documentation (opens in a new tab) for more information on editing a Worker.

const seoTargetBase = 'https://portal.pseo.one';
 
export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url);
    const origin = url.origin;
    const pathname = url.pathname;
 
    if (pathname.startsWith("/yoursubpath")) {
      const targetUrl = seoTargetBase + url.pathname + url.search;
 
      const newHeaders = new Headers(request.headers);
      newHeaders.set('x-req-domain', origin);
 
      const newRequest = new Request(targetUrl, {
        method: request.method,
        headers: newHeaders,
        body: request.body,
        redirect: 'follow'
      });
 
      const response = await fetch(newRequest);
      return new Response(response.body, response);
    }
 
    return fetch(request);
  }
};
 

Select Deploy and wait for the changes to propagate (it can take up to a few hours).

Test your Worker

After your code deploys, test your Worker to ensure it routes to your GrackerAI portal.

  1. Test using the Worker's preview URL:

    your-worker.your-subdomain.workers.dev/yoursubpath

Add Route

To connect your Worker to your domain, you need to configure a route:

  1. In your Worker settings, navigate to the Domains & Routes tab

  2. Under Route,

  3. Enter your route pattern:

    yourdomain.com/yoursubpath/*
  4. Select your zone from the dropdown

  5. Click Save

Example route patterns:

  • example.com/portal/* - Routes all requests starting with /portal/
  • *.example.com/docs/* - Routes subdomains with /docs/ path

For more information on route patterns and configuration, see the Cloudflare Workers Routes documentation (opens in a new tab).

Custom Domain Setup with Cloudflare

This documentation provides a comprehensive guide for setting up custom domains using Cloudflare's Custom Hostname feature for GrackerAI's cybersecurity content marketing platform.

1. DNS setup

To connect your custom domain to your portal, you'll need to add a CNAME record in your Cloudflare DNS settings.

Add CNAME Record

In your Cloudflare dashboard:

  1. Navigate to DNS > Records
  2. Click Add record
  3. Configure the CNAME record as follows:
Type: CNAME
Name: your-subdomain (e.g., portal, ciam-101)
Target: portal.pseo.one
Proxy status: Proxied (orange cloud)

Example:

ciam-101.customer1.com → portal.pseo.one

DNS Propagation

After adding the CNAME record:

  • Changes typically propagate within 2-5 minutes when using Cloudflare's proxy
  • Full global propagation may take up to 24-48 hours
  • You can check propagation status using tools like DNS Checker (opens in a new tab)

Additional Resources