Netlify homepage w/ Ghost in subdirectory

Hi there,

I’ve been racking my brain for the past 2 days trying to figure out if what I want to do is even possible.

Ideally, this is what I want:

  1. Homepage of my site example.com served from Netlify & Gitlab
    (It’s a custom static page, no framework, etc.)

  2. Ghost running is a subfolder at example.com/blog/

Now, I can do either of these 2 successfully but I can’t do both at the same time.

I have Ghost running on DigitalOcean in a subfolder /blog/ but when trying to access the root domain I get: 403 Forbidden nginx/1.14.0 (Ubuntu)

So finally my question… is there a way to setup nginx to look for my homepage on Netlify?

Best,
Hristian

1 Like

It’s not in English but I have written something that you want to look at, so just use the google to translate it to English or your native language, either will work fine. FYI instead of using gitlab you can use the same droplet with your ghost blog and your static website. This is what I actually do and explained in that story https://cemates.me/blog/ghost-blog-alt-klasore-nasil-tasinir/ :slight_smile:

1 Like

Hi @CemAtes,

Thank you for providing an alternative but I really like to keep the Netlify setup for now.

There are of course, various other ways to do this that doesn’t involve Netlify but I want to see if it is possible to have the homepage loaded through Netlify.

Best,
Hristian

Yes you can! Nginx is a reverse proxy, so you can configure one location block to try netlify and one to try your ghost instance! Here’s a snippet from what I use:

location / {
  try_files $uri $uri/ @netlify;
 }

location /blog {
  # Include Ghost config here!
}

location @netlify {
  proxy_pass https://<SITENAME>.netlify.com;
  include /etc/nginx/proxy_params;
}

You can try using a proxy redirect rule to allow you to serve your subdomain via the the /blog path. You can read how to this is done here: Redirects and rewrites | Netlify Docs. Although I haven’t been able try that yet, but this is what netlify customer support said.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.