e98f8561f7
mirror-to-gitee / mirror (push) Successful in 9s
问题:容器重建换 IP 后,网关与 admin-ui 仍往旧 IP 打,/openapi 与 /api 整片 502,必须手动重启 nginx 容器才恢复(2026-11-03 实机踩到)。 编排 - admin-svr / openapi / admin-ui / docs 增加 healthcheck - admin-ui、gateway、nginx 改 depends_on: condition: service_healthy, 保证 nginx 启动时后端已就绪 - 新增 deploy/compose.memlimit.yml(原来只存在于某台演示机上): 全套上限 8.5G、实测常驻 2G,留给同机其它服务 20G+; MySQL buffer pool 128M→768M、max_connections 151→300 nginx - gateway / admin-ui / iotlcm.conf 示例 统一改 resolver 127.0.0.11 valid=10s + upstream zone/resolve:运行期跟随 IP 变化,不必重启(实测 6s 内自愈)
68 lines
2.1 KiB
Plaintext
68 lines
2.1 KiB
Plaintext
# DNS 解析:nginx 只在启动时解析一次 upstream 主机名,admin-svr 重建换 IP 后
|
||
# /api/ 会一直 502。127.0.0.11 是 Docker 内置 DNS,resolve + zone 让运行期自动跟随。
|
||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||
|
||
upstream gw_admin_svr { zone gw_admin_svr 64k; server admin-svr:8008 resolve; }
|
||
|
||
server {
|
||
listen 80;
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
|
||
charset utf-8;
|
||
client_max_body_size 200m;
|
||
access_log /var/log/nginx/access_admin-ui.log;
|
||
error_log /var/log/nginx/error_admin-ui.log;
|
||
|
||
# 入口 HTML 不强缓存,保证发布后立即生效
|
||
location = /index.html {
|
||
try_files $uri =404;
|
||
add_header Cache-Control no-cache,no-store,must-revalidate always;
|
||
add_header Pragma no-cache always;
|
||
add_header Expires 0 always;
|
||
}
|
||
|
||
# 运行时配置文件不强缓存
|
||
location ~* ^/(?:_app[.]config[.]js|config[.]json|menu-setting[.]json|setting[.]json)$ {
|
||
try_files $uri =404;
|
||
add_header Cache-Control no-cache,no-store,must-revalidate always;
|
||
add_header Pragma no-cache always;
|
||
add_header Expires 0 always;
|
||
}
|
||
|
||
# 带 hash 的静态资源长期缓存
|
||
location ~* ^/(?:js|jse|css)/ {
|
||
try_files $uri =404;
|
||
add_header Cache-Control public,max-age=31536000,immutable always;
|
||
}
|
||
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# 后端 API 转发(同 compose 内服务名)
|
||
location /api/ {
|
||
proxy_set_header Connection upgrade;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_http_version 1.1;
|
||
chunked_transfer_encoding off;
|
||
proxy_pass http://gw_admin_svr/api/v1/;
|
||
proxy_redirect off;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
}
|
||
|
||
# 上传文件目录(与 admin-svr 共享同一挂载卷)
|
||
location /upload/ {
|
||
alias /app/upload/;
|
||
}
|
||
|
||
location /app/upload/ {
|
||
alias /app/upload/;
|
||
}
|
||
|
||
gzip on;
|
||
gzip_types text/plain application/javascript text/css application/json;
|
||
}
|