# ============================================================ # OpenHIS 前端 Nginx 配置 # 放到 /etc/nginx/conf.d/openhis.conf 或 include 到 nginx.conf # ============================================================ server { listen 80; server_name openhis.local; # 改成实际域名或 IP # 前端静态文件 location / { root /usr/share/nginx/html/openhis; index index.html; try_files $uri $uri/ /index.html; # SPA 路由回退 } # 后端 API 代理 location /prd-api/ { proxy_pass http://127.0.0.1:18080/openhis/; 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_connect_timeout 300; proxy_read_timeout 300; client_max_body_size 50m; } # gzip 压缩(Vite 构建已生成 .gz 文件,Nginx 直接发送) gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; gzip_min_length 1024; gzip_comp_level 6; gzip_vary on; # 静态资源缓存(带 hash 的文件长期缓存) location ~* /assets/.*\.(js|css|woff2?|ttf|eot|png|jpg|jpeg|gif|svg|ico)$ { root /usr/share/nginx/html/openhis; expires 365d; add_header Cache-Control "public, immutable"; } # index.html 不缓存(保证更新及时生效) location = /index.html { root /usr/share/nginx/html/openhis; add_header Cache-Control "no-cache, no-store, must-revalidate"; } }