It's possible to setup a reverse proxy using Cloudflare Workers to establish a subdirectory on Ghost(Pro).

For this configuration to work successfully, you must be on a Business plan with a subdirectory enabled. You must also paste the exact configuration below into the Worker script area, updating each line as specified so that it meets our reverse proxy rules.

Use of Cloudflare Workers for a subdirectory setup is considered highly advanced and may require additional technical knowledge and troubleshooting. The below configuration has been tested and works with these exact settings if there are no conflicting top-level config issues.

Note: Ensure that your setup references the subdirectory path you are wanting to use (e.g. /^\\/blog/).

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

/**
 * Respond to the request
 * @param {Request} request
 */
async function handleRequest(request) {
     try {
      
        const urlObject = new URL(request.url);

        // If the request is to the Ghost subdirectory
        if (/^\/blog/.test(urlObject.pathname)) {
          // Then Proxy to Ghost
          const GHOST_URL = "subdomain.ghost.io";
          const CUSTOM_URL = "customdomain.com"; 

          let url = new URL(request.url);

          url.hostname = GHOST_URL;

          let proxyRequest = new Request(url, request);

          proxyRequest.headers.set('Host', GHOST_URL);

          //Have an X-Forwarded-Host header that matches the custom domain in my.ghost.org.

          proxyRequest.headers.set("X-Forwarded-Host", CUSTOM_URL);

          //Include the X-Forwarded-Proto header set to https not http.

          proxyRequest.headers.set("X-Forwarded-Proto", "https");

          //Include the X-Forwarded-For header, populated with the remote IP of the original request.

          let ip = proxyRequest.headers.get("CF-Connecting-IP");

          proxyRequest.headers.set("X-Forwarded-For", ip);

          return await fetch(proxyRequest);

        }

     } catch (error) {

        // if no action found, play the regular request

        return await fetch(request);
    }

    return await fetch(request);
}