Reverse proxy using apache and cloudflare

So Im using apache to reverse proxy the ghost domain. I was hoping to have my ghost site live on https:///

here is what I have in my ssl.conf

SSLProxyEngine On
<Location /blog/>

Seems apache is doing its job but then I get a Domain error
Failed to resolve DNS path for this host with in url bar when i try navigating to https:///

Im using cloudflare for the entire domain if that makes a difference.

Any help or suggestions would be appreciated.

You should be proxying localhost:port, and setup your Ghost config for the FQDN, plus routes for /blog.

1 Like

I see, so I’ll need to use the open source version of ghost CMS correct?

Im using Ghost pro and from what I understand this is something that will cost me $300 a month? (200 for business and 100 for the subdirectory add-on)?

Ghost Pro expects to serve your domain with the name that you have pointing at it, with a CNAME and A record. You can’t set it up to serve your site at if you don’t have the DNS record pointed at it along with a www. A record that’s a CNAME for your domain. [If you’re setting up with cloudflare, I’ve had best success with the proxying turned off while I got the domain through the Ghost verification process.]

If you want to stay with Ghost Pro, you could have a Cloudflare proxy in front of your Ghost Pro site and accomplish this with a worker that does some rewriting. [This could probably also be done with Apache, but I think you’re going to get better results from Cloudflare, especially if you’re already proxying with them.

So what you can do is set up Ghost Pro with a record, and then use a Cloudflare worker to respond to requests for* with the response from*. Some rewriting of the URLs within the response body will probably also be necessary


I like this but there is an entire site that lives on domain so when I try to add the CNAME www to the ghost subdomain cloudflare gives me an error that one exists. Im basically trying to replace the WP blog that lives in that subdirectory on my server.The routing with ghost pro looks good, if I replace the ghost subdomain with that would suffice.

Appreciate your suggestions

The root domain record is not required. If you have a cname from to the subdomain, you should be sble to activate.

1 Like

so close!

i have the blog on working with CF workers.

The links generated for the posts ( i had imported posts earlier) … dont have the /blog/ so they 404 … the routes.yaml

I tried

## routes.yaml


    permalink: /blog/{slug}/
    template: index

  tag: /blog/tag/{slug}/
  author: /blog/author/{slug}/

and chatgpt 4 suggested


    permalink: /blog/{slug}/
    template: index

  tag: /blog/tag/{slug}/
  author: /blog/author/{slug}/

and the worker ( also thanks to chatgpt)

addEventListener('fetch', event => {

async function handleRequest(request) {
  const url = new URL(request.url)
  if (url.pathname.startsWith('/blog/')) {
    const blogURL = '' + url.pathname.replace('/blog', '')
    const response = await fetch(blogURL, request)

    // Check if the content is HTML
    const contentType = response.headers.get('content-type')
    if (contentType && contentType.includes('text/html')) {
      let body = await response.text()

      // Rewrite links in the HTML content
      body = body.replace(/https:\/\/blog\.example\.com\//g, '')

      return new Response(body, {
        status: response.status,
        statusText: response.statusText,
        headers: response.headers

    return response

  return fetch(request)

whats interesting is the “about” url works … it has the /blog/ in it.

Any ideas? :face_with_peeking_eye:

Edit My mistake and this works! I re-read the docs and I probably had spacing issues with the YAML file.

The most important thing to know when working with YAML is that it uses indentation to denote structure. That means the only type of nesting which works is 2 spaces.

The most common reason for YAML files not working is when you accidentally use the wrong type or quantity of spacing for indentation. So keep a close eye on that!

Thank you very much @Cathy_Sarisky