Skip to main content

Auto-Discovery API

The API allows backends to automatically register and deregister.

Endpoints

MethodEndpointDescription
GET/healthHealth check + version + backend count
POST/api/v1/registerRegister a new backend
POST/api/v1/heartbeat/:idUpdate backend heartbeat
GET/api/v1/backendsList all registered backends
GET/api/v1/backends/:idGet specific backend details
DELETE/api/v1/backends/:idDeregister a backend

Configuration

VariableDefaultDescription
EDGEPROXY_API_ENABLEDfalseEnable Auto-Discovery API
EDGEPROXY_API_LISTEN_ADDR0.0.0.0:8081API listen address
EDGEPROXY_HEARTBEAT_TTL_SECS60Backend heartbeat TTL

Registration Example

# Enable API
export EDGEPROXY_API_ENABLED=true
export EDGEPROXY_API_LISTEN_ADDR=0.0.0.0:8081
export EDGEPROXY_HEARTBEAT_TTL_SECS=60

# Register a backend
curl -X POST http://localhost:8081/api/v1/register \
-H "Content-Type: application/json" \
-d '{
"id": "backend-eu-1",
"app": "myapp",
"region": "eu",
"ip": "10.50.1.1",
"port": 8080,
"weight": 2,
"soft_limit": 100,
"hard_limit": 150
}'

# Send heartbeat (keep alive)
curl -X POST http://localhost:8081/api/v1/heartbeat/backend-eu-1

# List all backends
curl http://localhost:8081/api/v1/backends

Registration Payload

{
"id": "backend-eu-1",
"app": "myapp",
"region": "eu",
"country": "DE",
"ip": "10.50.1.1",
"port": 8080,
"weight": 2,
"soft_limit": 100,
"hard_limit": 150
}
FieldRequiredDefaultDescription
idYes-Unique backend identifier
appYes-Application name
regionYes-Region code (sa, us, eu, ap)
countryNoderivedCountry code (ISO 3166-1)
ipYes-Backend IP address
portYes-Backend port
weightNo2Load balancing weight
soft_limitNo100Soft connection limit
hard_limitNo150Hard connection limit

Health Check Response

curl http://localhost:8081/health
{
"status": "ok",
"version": "0.2.0",
"backends": 5,
"uptime_secs": 3600
}

Benefits

  • Zero configuration: Backends just start and register
  • Automatic scaling: New instances appear automatically
  • Graceful shutdown: Clean deregistration
  • TTL-based health: Unhealthy = expired = deregistered