# Plaza bootstrap（首次部署、尚未签发证书）
# 仅 HTTP :80，用于 certbot webroot

upstream goose_plaza_web_bootstrap {
    server 127.0.0.1:3002;
    keepalive 8;
}

upstream goose_plaza_api_bootstrap {
    server 127.0.0.1:8080;
    keepalive 8;
}

server {
    listen 80;
    listen [::]:80;
    server_name plaza.tkmind.cn;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location ^~ /api/ {
        proxy_pass http://goose_plaza_api_bootstrap;
        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 120;
        proxy_buffering off;
    }

    location ^~ /auth/ {
        proxy_pass http://goose_plaza_api_bootstrap;
        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_buffering off;
    }

    location ^~ /u/ {
        proxy_pass http://goose_plaza_api_bootstrap;
        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 120;
        proxy_buffering off;
    }

    location / {
        proxy_pass http://goose_plaza_web_bootstrap;
        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_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 120;
        proxy_buffering off;
    }
}
