- 添加 Traefik 网关配置,启用 ping 健康检查 - 配置 nginx-webws 服务处理 /ABM 路径 - 实现 HTTP 到 HTTPS 自动重定向 - 使用 rewrite 规则正确处理 /ABM/ 路径前缀 - 添加静态资源缓存优化(CSS/JS/JSON/图片) - 配置 PostgreSQL 数据库服务 网站访问地址: https://amiap.hzau.edu.cn/ABM/ 所有静态资源(HTML/CSS/JS/JSON/图片)均可正常访问
37 lines
815 B
Nginx Configuration File
37 lines
815 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name localhost;
|
|
|
|
# ABM 项目根目录
|
|
root /usr/share/nginx/html;
|
|
index index.html index.htm;
|
|
|
|
# ABM 主路径 - 重写 /ABM 到根目录
|
|
location /ABM/ {
|
|
rewrite ^/ABM/(.*)$ /$1 break;
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
# 静态资源缓存
|
|
expires 1d;
|
|
add_header Cache-Control "public, max-age=86400";
|
|
}
|
|
|
|
# 处理 /ABM 不带斜杠的情况
|
|
location = /ABM {
|
|
return 301 /ABM/;
|
|
}
|
|
|
|
# 健康检查端点
|
|
location /health {
|
|
access_log off;
|
|
return 200 "healthy\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
location = /50x.html {
|
|
root /usr/share/nginx/html;
|
|
}
|
|
}
|