# WordLoop 生产环境 Nginx（监听本机 8080，由 cloudflared 或上游反代转发）
# 安装：sudo cp deploy/nginx.conf /etc/nginx/sites-available/wordloop
#       sudo ln -sf /etc/nginx/sites-available/wordloop /etc/nginx/sites-enabled/
#       sudo nginx -t && sudo systemctl reload nginx

server {
    listen 127.0.0.1:8080;
    server_name w.tkmind.cn;

    root /var/www/wordloop/frontend/dist;
    index index.html;

    client_max_body_size 10m;

    location /api/ {
        proxy_pass http://127.0.0.1:18004;
        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;
    }

    location /docs {
        proxy_pass http://127.0.0.1:18004;
        proxy_set_header Host $host;
    }

    location /openapi.json {
        proxy_pass http://127.0.0.1:18004;
        proxy_set_header Host $host;
    }

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