blob: 98ba7fc6ca772e8fa453f34ac2afcb60c2c83278 [file] [log] [blame]
223011114511d212025-06-05 18:36:11 +08001server {
2 listen 80;
3 server_name localhost team11.10813352.xyz;
4
5 # 前端请求(React 静态资源)
6 location / {
7 root /usr/share/nginx/html; # React 构建文件默认位置
8 index index.html;
9 try_files $uri $uri/ /index.html; # 支持前端路由
10 }
11
12 # 后端 API 请求
13 location /echo {
14 proxy_pass http://backend:5011; # 转发到后端容器
15 proxy_set_header Host $host;
16 proxy_set_header X-Real-IP $remote_addr;
17 }
223011118c887862025-06-05 20:57:18 +080018
19 # 静态图片资源
20 # 方案1:直接通过Nginx提供静态文件
21 location /uploads/ {
22 alias /usr/share/nginx/html/uploads/;
23 expires 30d;
24 }
25 # 方案2:代理到后端服务(如果后端需要处理文件访问逻辑)
26 # location /uploads/ {
27 # proxy_pass http://backend:5011;
28 # proxy_set_header Host $host;
29 # }
223011114511d212025-06-05 18:36:11 +080030}