如何在不修改 API 地址的情况下重新路由 Ghost 博客管理员 URL?

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

Ghost 博客平台有一个设置,允许您更改管理面板登录位置(开头为:https://whateveryoursiteis.com/ghost). Methodology / docs for changing that setting can be found here: https://ghost.org/docs/config/#admin-url

但是 — 当使用上述方法时,用于搜索等的 API Url 也被修改,这意味着对 ghost API 的所有请求也将被转发到备用域(不仅仅是管理员访问权限)。

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?

更多背景。

我们是 运行 GKE (Google Kubernetes Engine) 上的多区域入口上的幽灵,这允许我们将我们的云 SQL 数据库转储到 SQLite 文件,然后将该数据库构建到我们的生产 Docker 容器中,然后将其部署到由 GCE-Ingress 负载均衡器前端的不同 Kubernetes 节点。

由于我们需要在内容更改时重建该数据库/容器(不仅仅是代码更改),我们需要一个单独的管理员 URL 由 Cloud SQL 支持,我们可以在其中保存/修改我们的数据然后通过 Ghost Webhooks 在我们的 Ci 管道上触发重建。

另一个相关问题可能是:

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)?

另一个相关的 GKE/GCE-Ingress 问题:

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

这将是我发布此消息后的第一次尝试 — 但我认为无论哪种方式,它都可以帮助另一个幽灵平台粉丝在某个地方下线 — 当我找到这些问题的答案时,我会尝试回复(假设有人不不要打败我!)。

关于您的问题是否可以在不添加 nginx 容器的情况下创建 301 重定向,我可以建议使用 istio,了解有关流量路由的更多信息here

好的。因此,事实证明,Ghost 团队目前已将 API 连接指向管理员 URL。因此,如果您更改管理员 URL,则希望您的客户尝试连接到 URL。

我将在幽灵论坛上提出将这些作为功能请求拆分的可能性(一旦我从当前项目的预发布地狱中解脱出来)。

这是 Ghost 的官方回复:

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.

在 TryGhost GitHub 上查看完整讨论: https://github.com/TryGhost/Ghost/issues/10441#issuecomment-460378033

我还没有研究实现该功能需要什么,但是关于代理请求的建议可能有效...如果我不需要 运行 在 GKE 多区域(哪个需要使用不支持重定向的 GCE-Ingress 哈!)。这样解决nGinx ingress会比较容易

希望这对某人有所帮助——我会在完成整个过程时进行更新。截至目前,我通过在构建期间将我的 GCP CloudSQL 数据库转储到 SQLite 数据库文件来解决它(从而允许我保持我的管理实例干净并与 API 端点分开——对我来说保持不变 URL).