So Im using apache to reverse proxy the ghost domain. I was hoping to have my ghost site live on https:///www.example.com/blog/
here is what I have in my ssl.conf
SSLProxyEngine On
<Location /blog/>
ProxyPass https://the-acme-blog.ghost.io
ProxyPassReverse https://the-acme-blog.ghost.io
</Location>
Seems apache is doing its job but then I get a Domain error Failed to resolve DNS pathfor this host with https://error.ghost.org/ in url bar when i try navigating to https:///www.example.com/blog/
Im using cloudflare for the entire domain if that makes a difference.
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 http://yoursite.com if you don’t have the yoursite.com DNS record pointed at it along with a www. A record that’s a CNAME for your ghost.io 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 blog.yoursite.com record, and then use a Cloudflare worker to respond to requests for yoursite.com/blog/* with the response from blog.yoursite.com/*. 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 yoursite.com 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 example.com/blog/ that would suffice.
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url)
if (url.pathname.startsWith('/blog/')) {
const blogURL = 'https://blog.example.com' + 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, 'https://www.example.com/blog/')
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?
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!