How do I Re-route Ghost Blog Admin URL without modifying the API Address?

1/31/2019

Ghost blog platform has a setting that allows you to change the admin panel login location (which starts as: https://whateveryoursiteis.com/ghost). Methodology / docs for changing that setting can be found here: https://docs.ghost.org/concepts/config/#admin-url

However — when using the above methodology the API Url that is used for Search etc etc is ALSO modified meaning all requests to the ghost API will also be forwarded to the alternate domain (not just the admin access).

My question is — what is the best way to achieve a redirect of the admin URL to a different Domain / protocol while allowing the API url used by Ghost to remain the same?

More background.

We are running ghost on top of GKE (Google Kubernetes Engine) on a Multi-Region Ingress which allows us to dump our CloudSQL DB down to a SQLite file and then build that database into our production Docker Containers which are then deployed to the different Kubernetes nodes that are fronted by the GCE-Ingress load balancer.

Since we need to rebuild that database / container on content change (not just on code change) we need to have a separate Admin URL backed by Cloud SQL where we can persist / modify our data which then triggers the rebuild on our Ci pipeline via Ghost Webhooks.

Another related question might be:

Is it possible to use standard ghost redirects (created via: https://docs.ghost.org/concepts/redirects/) to redirect the admin panel URL (ie. https://whateveryoursiteis.com/ghost) to a different domain (ie. https://youradminsite.com/ghost)?

Another Related GKE / GCE-Ingress Question:

Is it possible to create 301 redirects natively using Kuberentes GCE-Ingress on GKE without adding an nGinx container etc?

That will be my first attempt after posting this — but I figured either way maybe it helps another ghost platform fan down the line someplace — I will attempt to respond back as I find answers to those questions (assuming someone doesn't beat me to it!).

-- Necevil
ghost-blog
google-kubernetes-engine
kubernetes
kubernetes-ingress

2 Answers

1/31/2019

Regarding your question if it's possible to create 301 redirects without adding a nginx container, I can suggest to use istio, find out more information about traffic routing here.

-- kornshell93
Source: StackOverflow

2/8/2019

OK. So as it turns out the Ghost team currently has things setup to point API connections at the Admin URL. So if you change your Admin URL expect your clients to attempt to connect to that URL.

I am going to be raising the potential of splitting these off as a feature request over on the ghost forums (as soon as I get out from under pre-launch hell on the current project).

Here's the official Ghost response:

What is referred as 'official docker image' is not something that we as a Ghost team support.

The APIs are indeed hosted under the same URL as the admin and that's by design and not really a bug. Introducing configuration options for each API Ghost instance hosts would be a feature and should be discussed at our forum first I think it's a nice idea to be able to serve APIs from different host, but it's not something that is within our priorities at the moment.

In case you need more granular handling of admin site, you could introduce those on your proxy level and for example, handle requests that are coming to /ghost/api with a different set of rules.

See the full discussion over here on the TryGhost GitHub: https://github.com/TryGhost/Ghost/issues/10441#issuecomment-460378033

I haven't looked into what it would take to implement the feature but the suggestion on proxying the request could work... if only I didn't need to run on GKE Multi region (which requires use of GCE-Ingress which doesn't have support for redirection hah!). This would be relatively easy to solve the nGinx ingress.

Hopefully this helps someone — I will update as I work through the process. As of now I solved it by dumping my GCP CloudSQL database down to a SQLite db file during build time (thereby allowing me to keep my admin instance clean and separate from the API endpoint — which for me remains the same URL).

-- Necevil
Source: StackOverflow