-
Notifications
You must be signed in to change notification settings - Fork 51
Move API healthcheck endpoint from /health_check to /api/v1/health_check #537
Description
I'm working on setting up a live demo on https://index.torrust-demo.com/.
See torrust/torrust-compose#2.
I'm using Nginx as a reverse proxy. The HTTP tracker has these direct URLs:
- API: http://tracker.torrust-demo.com:1212/health_check
- HTTP Tracker: http://tracker.torrust-demo.com:7070/health_check
- UDP Tracker: udp://tracker.torrust-demo.com:6969
But you can load them via the reverse proxy with https:
- API: http://tracker.torrust-demo.com/api/health_check -> The API healthcheck endpoint.
- HTTP Tracker: http://tracker.torrust-demo.com/health_check -> This is the HTTPO tracker healthcheck endpoint.
The API healthcheck endpoint is not accessible from the proxy because I'm using the URL segment api to redirect requests for the Tracker API.
HTTP Nginx config for the tracker:
server
{
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name tracker.torrust-demo.com;
location /api/
{
proxy_pass http://tracker:1212/api/;
}
location /
{
proxy_pass http://tracker:7070;
}
location ~ /.well-known/acme-challenge
{
allow all;
root /var/www/html;
}
}
The reason I used the endpoint /health_check instead of /api/v1/health_check is because:
- I wanted a generic API healthcheck regardless of the API version.
- I wanted that endpoint to be public, not requiring a token.
I could add a new redirection in the Nginx configuration, something like:
location /health_check
{
proxy_pass http://tracker:1212/health_check;
}
However, the HTTP Tracker health check endpoint would not be accessible.
Maybe I can use /api/health_check and apply the auth middleware only to /api/v1/*.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status