Files
iot-device-management-frontend/apps/web-antd/nginx.conf
lzh 2fa613fd44 build(ci): 新增 CI/CD 配置 + 修复 3 个部署 bug
新增:
- Jenkinsfile:master→PROD(172.17.16.14)、release/next→STAGING(172.17.16.7)
  镜像推 172.17.16.7:5000/aiot-iot-ui,宿主机暴露 90
- docker-compose.frontend.yml:nginx 容器加入 1panel-network
- 根 Dockerfile + apps/web-antd/nginx.conf:与 vben 前端结构对齐
  nginx 反代 /admin-api → http://aiot-gateway:48080

修复:
- .env.production VITE_GLOB_API_URL 硬编码 127.0.0.1 → /admin-api(走 nginx 反代)
- scripts/deploy/Dockerfile 引用不存在的 playground/dist → apps/web-antd/dist
  并改用 turbo 单 filter 构建(与根 Dockerfile 一致)
2026-04-28 14:40:47 +08:00

65 lines
2.0 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 配置 DNS 解析器(使用 Docker 内置 DNS 解析容器名)
resolver 127.0.0.11 valid=30s;
server {
listen 80;
server_name localhost;
# 开启 gzip 压缩
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
root /usr/share/nginx/html;
index index.html;
# API 反向代理到后端服务
# 后端容器名为 aiot-gateway与本前端容器需在同一 Docker 网络1panel-network
location /admin-api {
client_max_body_size 100M;
proxy_pass http://aiot-gateway:48080/admin-api;
proxy_connect_timeout 10s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
# 后端短暂不可达时尝试一次重试
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_next_upstream_tries 2;
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;
# 跨域响应头(仅作兜底,正常同域不会触发)
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
if ($request_method = 'OPTIONS') {
return 204;
}
}
# SPA 路由刷新兜底
location / {
try_files $uri $uri/ /index.html;
}
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}