server { listen 80; server_name glucowise.site www.glucowise.site; root /var/www/glucowise; index index.html; # Let's Encrypt验证目录 location /.well-known/acme-challenge/ { root /var/www/glucowise; allow all; } # 临时允许HTTP访问(申请证书后会重定向到HTTPS) location / { try_files $uri $uri/ /index.html; } # 后端API代理 location /api/ { proxy_pass http://127.0.0.1:8080; 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; } }