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
- Log in to the Cloudflare dashboard and select your account.
- Select Workers & Pages.
- Select your application.
- 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.
-
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:
-
In your Worker settings, navigate to the Domains & Routes tab
-
Under Route,
-
Enter your route pattern:
yourdomain.com/yoursubpath/*
-
Select your zone from the dropdown
-
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:
- Navigate to DNS > Records
- Click Add record
- 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)