| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- server {
- listen 80;
- server_name _;
- # Gzip compression for API responses and static assets
- gzip on;
- gzip_types application/json text/plain text/css application/javascript;
- gzip_min_length 1000;
- gzip_comp_level 6;
- # 前端静态文件
- location / {
- root /usr/share/nginx/html;
- index index.html;
- try_files $uri $uri/ /index.html;
- # Cache static assets
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf)$ {
- expires 7d;
- add_header Cache-Control "public, max-age=604800, immutable";
- }
- }
- # Health check (no proxy)
- location /ping {
- proxy_pass http://api:8080;
- proxy_connect_timeout 5s;
- proxy_read_timeout 5s;
- }
- # API 代理(含 WebSocket)
- location /api/ {
- proxy_pass http://api:8080;
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- 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_read_timeout 300s;
- proxy_send_timeout 300s;
- # Larger buffer for big API responses
- proxy_buffer_size 16k;
- proxy_buffers 8 32k;
- # No caching for API
- add_header Cache-Control "no-cache, no-store, must-revalidate";
- }
- }
|