Skip to content

Move API healthcheck endpoint from /health_check to /api/v1/health_check #537

@josecelano

Description

@josecelano

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:

But you can load them via the reverse proxy with https:

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/*.

What do you think @da2ce7 @WarmBeer?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions