blob: c9be40938fcb0f04b07372f0cc85c5e9363357f5 [file] [log] [blame]
yyyang3bd72f02025-06-03 16:35:11 +08001server {
2 listen 80;
3 server_name localhost;
4
5 root /usr/share/nginx/html;
6 index index.html;
7
8 # 开启 gzip 压缩
9 gzip on;
10 gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
11
12 # 所有静态资源
13 location / {
14 try_files $uri $uri/ /index.html;
15 }
16
17 # 后端 API 代理
18 location /api/ {
19 proxy_pass http://backend:8080/api/;
20 proxy_http_version 1.1;
21 proxy_set_header Upgrade $http_upgrade;
22 proxy_set_header Connection 'upgrade';
23 proxy_set_header Host $host;
24 proxy_set_header X-Real-IP $remote_addr;
25 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
26 proxy_set_header X-Forwarded-Proto $scheme;
27 proxy_cache_bypass $http_upgrade;
28 }
29}