server {
  listen 80;
  listen [::]:80;
  server_name ai.51easyai.com;
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name ai.51easyai.com;

  ssl_certificate /etc/nginx/tls/ai.51easyai.com/fullchain.pem;
  ssl_certificate_key /etc/nginx/tls/ai.51easyai.com/privkey.pem;
  ssl_protocols TLSv1.2 TLSv1.3;

  location ^~ /api/ {
    default_type application/json;
    add_header Retry-After 600 always;
    return 503 '{"error":{"message":"Gateway database maintenance is in progress","type":"service_unavailable"}}';
  }

  location / {
    default_type text/html;
    add_header Retry-After 600 always;
    return 503 '<!doctype html><html lang="zh-CN"><meta charset="utf-8"><title>系统维护</title><style>body{font-family:sans-serif;max-width:40rem;margin:15vh auto;padding:2rem;color:#1f2937}h1{font-size:1.8rem}</style><h1>系统正在进行高可用升级</h1><p>预计 5–10 分钟恢复，请稍后重试。</p></html>';
  }
}
