# 80 端口: 强制跳转到 443
server {
    listen 80;
    listen [::]:80;
    server_name api.duobibi.com;
    return 301 https://$host$request_uri;
}

# 443 端口: 反代到本地 uvicorn (多比比独立端口 8766,与傻瓜比价 8765 并存)
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name api.duobibi.com;

    ssl_certificate     /etc/nginx/ssl/api.duobibi.com.pem;
    ssl_certificate_key /etc/nginx/ssl/api.duobibi.com.key;

    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;

    # Android 控件树最大上限 ~3MB;截图客户端兜底 5MB + multipart overhead → 6MB
    client_max_body_size 6m;

    location / {
        proxy_pass http://127.0.0.1:8766;
        proxy_http_version 1.1;
        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;
        proxy_read_timeout 30s;
    }
}
