{
	# Disable the admin endpoint — not needed for this stack
	admin off
	# Auto HTTPS off for the local stack; flip on by using a real hostname instead of :80
	auto_https off
}

:80 {
	# Backend API: round-robin across the two backend instances
	handle /api/* {
		reverse_proxy backend-1:3000 backend-2:3000 {
			lb_policy round_robin
			# Active health checks: probe each backend every second; unhealthy
			# ones are removed from rotation and re-added as soon as probes pass
			health_uri /api/health
			health_interval 1s
			health_timeout 2s
			# In-flight failover: if a request hits a backend right as it dies,
			# retry the other upstream within this window
			lb_try_duration 1s
			# Stamp the upstream that served the response (used by the lb-* demo scripts)
			header_down +X-Upstream {http.reverse_proxy.upstream.hostport}
		}
	}

	# Static SPA with client-side routing fallback
	handle {
		root * /srv
		try_files {path} /index.html
		file_server
	}

	encode zstd gzip

	log {
		output stdout
		format console
	}
}
