server {
  listen 80 default_server;
  server_name "";

  location = /health {
    access_log off;
    default_type text/plain;
    return 200 "ok\n";
  }

  location / {
    return 444;
  }
}

server {
  listen 80;
  server_name __APP_EXTERNAL_HOST__;

  add_header X-Content-Type-Options "nosniff" always;
  add_header X-Frame-Options "DENY" always;
  add_header Referrer-Policy "strict-origin-when-cross-origin" always;
  add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

  root /usr/share/nginx/html;
  index index.html;

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

  location = /health {
    proxy_pass http://backend-web:8080/health;
    proxy_http_version 1.1;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    # Traefik replaces these headers. Pass its sanitized values rather than appending another
    # hop or replacing external HTTPS with nginx's internal HTTP scheme.
    proxy_set_header X-Forwarded-For $http_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
  }

  location /api/ {
    proxy_pass http://backend-web:8080;
    proxy_http_version 1.1;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $http_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
  }
}
