51 lines
1.8 KiB
Plaintext
51 lines
1.8 KiB
Plaintext
map $http_upgrade $connection_upgrade {
|
||
default upgrade;
|
||
'' close;
|
||
}
|
||
|
||
server {
|
||
listen 80;
|
||
server_name localhost;
|
||
|
||
# K8s 部署:proxy_pass 的服务名由 Jenkins envsubst '$KRA_APP' 渲染为 <APP_NAME>-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_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection $connection_upgrade;
|
||
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;
|
||
proxy_pass http://${KRA_APP}-backend:8000; # Kubernetes Service
|
||
}
|
||
|
||
location ^~ /api/ {
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection $connection_upgrade;
|
||
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;
|
||
proxy_read_timeout 600s;
|
||
rewrite ^/api/(.*)$ /$1 break;
|
||
proxy_pass http://${KRA_APP}-backend:8000;
|
||
}
|
||
|
||
location = /api/swagger/index.html {
|
||
proxy_http_version 1.1;
|
||
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;
|
||
proxy_pass http://${KRA_APP}-backend:8000/swagger/index.html;
|
||
}
|
||
}
|