If acme.com is on Cloudflare, a small Worker forwards /docs/* to your
NookDocs origin. See Host at a subpath for the overall model.
1. Create the Worker
In the Cloudflare dashboard → Workers & Pages → Create → Worker, paste this (replace the origin with your project's subdomain and adjust the path):
export default {
async fetch(request) {
const url = new URL(request.url);
// Only proxy the docs subpath; everything else hits your own origin.
if (url.pathname === "/docs" || url.pathname.startsWith("/docs/")) {
const target = new URL(request.url);
target.hostname = "acme.nookdocs.site";
target.protocol = "https:";
target.port = "";
const headers = new Headers(request.headers);
headers.set("X-Nookdocs-Host", "acme.com");
headers.set("X-Nookdocs-Base-Path", "/docs");
headers.set("Host", "acme.nookdocs.site");
return fetch(target, {
method: request.method,
headers,
body: request.body,
redirect: "manual",
});
}
return fetch(request);
},
};The dashboard generates this snippet with your exact origin, domain, and path pre-filled — Settings → Domains → Show proxy setup. Copy from there.
2. Add a route
Workers → your worker → Settings → Domains & Routes → Add route:
Route: acme.com/docs*
Zone: acme.comThe * is important — it matches /docs and everything beneath it.
3. Verify
curl -sI https://acme.com/docs | grep -i content-type # text/html from NookDocs
curl -s https://acme.com/docs/llms.txt | head -1 # # Your ProjectInternal links, assets, and canonical tags all resolve under acme.com/docs.
Notes
Other paths are untouched —
return fetch(request)passes everything outside/docs/*straight to your own origin.Redirects use
redirect: "manual"so NookDocs redirects (trailing-slash, configredirects) reach the visitor intact.If you send a CSP from your site, see CSP configuration.