Files
freedom-web/nginx.conf
T
张家训 64cdccfeb2
CI/CD Deploy (Web) / 构建前端镜像并部署 (push) Failing after 2s
feat: 娣诲姞 CI/CD 鑷姩鍖栭儴缃?(Dockerfile + Gitea Actions workflow)
2026-08-26 11:36:06 +08:00

59 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.
# =============================================================
# freedom 统一入口 Nginx 配置
# 同一域名路径区分:/api/* 反代到后端容器,其余走前端静态文件
#
# 后端接口无 /api 前缀,因此需要去掉前缀再转发。
# 后端容器服务名:backend,端口:8800(见 docker-compose.yml)
# =============================================================
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# 请求体大小限制(如有文件上传需求可调大)
client_max_body_size 20m;
# ---------------- API 反向代理 ----------------
# /api/xxx -> backend:8800/xxx (去掉 /api 前缀)
location /api/ {
proxy_pass http://backend:8800/;
proxy_http_version 1.1;
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_set_header Authorization $http_authorization;
proxy_connect_timeout 10s;
proxy_read_timeout 60s;
}
# ---------------- Excel 模板静态文件 ----------------
# 前端 nginxPath 指向 /excelTemplate.xxx,放在 Nginx 根目录静态文件
location = /excelTemplate {
alias /usr/share/nginx/html/;
}
location ~ ^/excelTemplate\.[a-zA-Z0-9]+$ {
try_files $uri =404;
}
# ---------------- 前端静态资源 + SPA 路由 ----------------
location / {
try_files $uri $uri/ /index.html;
}
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|woff2?|ttf|eot)$ {
expires 7d;
add_header Cache-Control "public, max-age=604800";
try_files $uri =404;
}
# 常见接口错误页面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}