web-projects/nginx/longde.cloud.conf
WangDL 03209e07fc
All checks were successful
Deploy Website / build-and-deploy (push) Successful in 8s
fix: add nginx API proxy config for /api/* → backend :3001
- Add nginx/longde.cloud.conf with /api/* proxy_pass to localhost:3001
- Update deploy.yml to install nginx config before deploying
- Fixes 405/502 errors when iOS app calls backend API

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 14:06:58 +08:00

52 lines
1.5 KiB
Plaintext

server {
listen 80;
server_name longde.cloud www.longde.cloud;
root /var/www/longde.cloud;
index index.html;
# Gzip
gzip on;
gzip_vary on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_types application/json text/plain text/css application/javascript image/svg+xml;
# API proxy to NestJS backend (Docker container on port 3001)
location /api/ {
proxy_pass http://localhost:3001/api/;
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 90s;
proxy_connect_timeout 10s;
client_max_body_size 10m;
}
# Swagger docs
location /api-docs {
proxy_pass http://localhost:3001/api-docs;
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 /api-docs-json {
proxy_pass http://localhost:3001/api-docs-json;
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;
}
# Frontend — SPA fallback
location / {
try_files $uri $uri/ /index.html;
}
}