Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[features] A health check endpoint #11181

Closed
lzhuor opened this issue Oct 1, 2019 · 13 comments
Closed

[features] A health check endpoint #11181

lzhuor opened this issue Oct 1, 2019 · 13 comments
Labels
feature request [triage] A feature request that belongs in ideas https://forum.ghost.org/c/Ideas/l/votes

Comments

@lzhuor
Copy link

lzhuor commented Oct 1, 2019

Could we please add a simple health api in index.js?

It will serve our needs for load balancers (GCP for us), site reliability monitoring. I am creating a PR for it but seeking for your advice in advance.

@rishabhgrg rishabhgrg added the feature request [triage] A feature request that belongs in ideas https://forum.ghost.org/c/Ideas/l/votes label Oct 7, 2019
@label-actions
Copy link

label-actions bot commented Oct 7, 2019

Hey @lzhuor 👋 Friendly reminder: we don't track feature requests on GitHub.

Please look for similar ideas to vote for on the forum and if you can't anything similar then post your own idea.

FYI: Many projects have their own support guidelines and GitHub will highlight them for you as it did here, or the project owners will use issue templates to point you in the right direction. Reading the guidelines or issue templates before opening issues can save you and project maintainers valuable time.

@label-actions label-actions bot closed this as completed Oct 7, 2019
@lzhuor
Copy link
Author

lzhuor commented Oct 13, 2019

Reopening

@jakubgs
Copy link

jakubgs commented Sep 3, 2020

Really? No healthcheck endpoint? Seriously?

@jakubgs
Copy link

jakubgs commented Sep 28, 2020

@lzhuor you said "Reopening" but you never reopened it.

@damusix
Copy link

damusix commented Sep 28, 2020

Having issues with a restarting container on ECS. Root gives me a 302 which is considered unhealthy. Ghost needs a healthcheck endpoint to keep up with modern deployment strategies...

@kevinansfield
Copy link
Member

If you need a 200 that isn't cached you can hit an API endpoint. /ghost/api/v3/admin/site/ is unauthenticated.

@jakubgs
Copy link

jakubgs commented Sep 29, 2020

 % curl -s 'http://localhost:8083/ghost/api/v3/admin/site/' -H 'X-Forwarded-Proto: https' | jq .
{
  "site": {
    "title": "Example",
    "description": "Example Blog",
    "logo": "/content/images/logo.png",
    "url": "https://blog.exampl.org/",
    "version": "3.27"
  }
}

Looks good. But how could I have possibly found this in the docs?

There should be a /health that shows essentially the same thing and be documented.

@ethankent
Copy link

Not having a health check route seems to make Ghost impossible to run behind a load balancer if you need https enabled.

@sneko
Copy link

sneko commented Apr 30, 2021

I totally agree, that's a total mess to make such a simple thing. I see 3 things here:

  • A dedicated endpoint should exist (since the "solution" above will vary depending on the Ghost version)
  • Even if HTTPS is used for the public/admin URL, the server should accept HTTP for the /health endpoint
  • Moreover, for the /health endpoint the server should not check the Host: xxxx header because it expect the defined URL so when doing it with localhost:2368/ghost/api/... the connection is refused.

I'm working on a Kubernetes environment, here is an example how you can set the healthchecks on your blog deployment:

        readinessProbe:
          httpGet:
            path: /ghost/api/v4/admin/site/
            port: deployment-port
            httpHeaders:
            - name: X-Forwarded-Proto
              value: https
            - name: Host
              value: blog.mydomain.com
        livenessProbe:
          httpGet:
            path: /ghost/api/v4/admin/site/
            port: deployment-port
            httpHeaders:
            - name: X-Forwarded-Proto
              value: https
            - name: Host
              value: blog.mydomain.com

Hope it helps ❤️

PS: thanks @jakubgs for pointing out the right URL to use 😃

@ErisDS
Copy link
Member

ErisDS commented Feb 1, 2022

The /ghost/api/admin/site/ endpoint is a great workaround for this.

There's a PR open to address this issue here: #13117 but as I've mentioned here, the thing that held me back from merging it is the lack of precedent and it also doesn't seem to really solve the problem above and beyond the /ghost/api/admin/site/ endpoint.

I'm more than happy to merge a PR that has a well thought out and evidenced solution for this :)

@debugger22
Copy link

/ghost/api/admin/site/ gives 301 instead of 200 for production.

@JaneJeon
Copy link

Of note: with ghost v5, it should be /ghost/api/admin/site, and not /ghost/api/v3/admin/site (or anything that's versioned).

@JaneJeon
Copy link

And @debugger22, you can bypass it by passing in the X-Forwarded-Proto: https header like others are mentioning here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request [triage] A feature request that belongs in ideas https://forum.ghost.org/c/Ideas/l/votes
Projects
None yet
Development

No branches or pull requests

10 participants