JWTPlus - Health Check API

Monitor the health of your JWTPlus service with this endpoint.

Endpoint

GET /health

Example Request

curl --request GET \
--url {{your-endpoint}}:{{your-port-number}}/health
const request = require('request');

const options = {method: 'GET', url: '{{your-endpoint}}:{{your-port-number}}/health'};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
}
import http.client

conn = http.client.HTTPConnection("localhost:1234")
conn.request("GET", "/health")

res = conn.getresponse()
data = res.read()     

print(data.decode("utf-8"))
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://localhost:1234/health');

echo $response->getBody();
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {

  url := "http://localhost:1234/health"

  req, _ := http.NewRequest("GET", url, nil)

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "http://localhost:1234/health")
  .execute()
  .toCompletableFuture()
  .thenAccept(System.out::println)
  .join();

client.close();

Example Success Response

{
"status": "ok"
}

Response Fields

Field Type Description
status string Health status of JWTPlus ("ok" = healthy).

Responses

Status Code Description
200 Ok The service is working normally.
503 Service Unavailable The service is not healthy or not ready to accept traffic.

Use Case

  • Used by load balancers (AWS ALB, Nginx, HAProxy) to monitor service health.
  • Ensures traffic is routed only to healthy instances.
  • Integrated into auto-scaling systems to avoid sending traffic to failing nodes.

Load Balancer Configuration

Nginx Configuration

location /health {
    proxy_pass http://jwtplus-instance:1234/health;
}

AWS ALB Health Check Settings

Setting Value
Protocol HTTP
Path /health
Port 1234
Success Codes 200
Interval 10 seconds
Unhealthy Threshold 3 failed checks