server {
  listen 80;
  server_name _;
  root /var/lib/nginx/html;
  index index.html;

  location /api/ {
    proxy_pass http://zeavis-api:3000/api/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

  # Expose API metrics through the web endpoint (Prometheus scrape target)
  location /metrics {
    proxy_pass http://zeavis-api:3000/metrics;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

  location / {
    try_files $uri $uri/ /index.html;
  }
}
