server { listen 80; server_name localhost; # K8s 部署:proxy_pass 的服务名由 Jenkins envsubst '$KRA_APP' 渲染为 -backend, # 产物写至 web/nginx.k8s.conf(不入库)。本地手动构建 web 镜像前需先执行渲染。 location / { root /usr/share/nginx/html; add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; try_files $uri $uri/ /index.html; } location /api { proxy_set_header Host $http_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; rewrite ^/api/(.*)$ /$1 break; #重写 proxy_pass http://${KRA_APP}-backend:8000; # Kubernetes Service } location /api/swagger/index.html { proxy_pass http://${KRA_APP}-backend:8000/swagger/index.html; } }