2026-06-09 09:30:43 +08:00
|
|
|
|
# Nginx 静态文件服务 + 前端入口兜底
|
2026-05-20 17:55:34 +08:00
|
|
|
|
|
2026-05-26 09:17:26 +08:00
|
|
|
|
# HTTP 重定向到 HTTPS
|
|
|
|
|
|
server {
|
|
|
|
|
|
listen 80;
|
|
|
|
|
|
server_name _;
|
|
|
|
|
|
return 301 https://$host$request_uri;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-20 17:55:34 +08:00
|
|
|
|
server {
|
2026-05-22 13:34:10 +08:00
|
|
|
|
# 静态资源根目录(dist)
|
2026-05-20 17:55:34 +08:00
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
|
|
index index.html;
|
|
|
|
|
|
|
|
|
|
|
|
# SSL 配置
|
|
|
|
|
|
listen 443 ssl;
|
2026-05-26 11:28:45 +08:00
|
|
|
|
ssl_certificate /etc/nginx/ssl/scs1779764972146_redpowerfuture.com_server.crt;
|
|
|
|
|
|
ssl_certificate_key /etc/nginx/ssl/scs1779764972146_redpowerfuture.com_server.key;
|
2026-05-20 17:55:34 +08:00
|
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
|
|
|
|
|
2026-06-09 09:30:43 +08:00
|
|
|
|
# 域名下任意未命中路径都不要落到 nginx 默认 404
|
|
|
|
|
|
error_page 404 = /web/index.html;
|
|
|
|
|
|
|
2026-05-22 13:34:10 +08:00
|
|
|
|
# 根路径默认进入网页端
|
|
|
|
|
|
location = / {
|
|
|
|
|
|
return 302 /web/index.html;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-09 09:30:43 +08:00
|
|
|
|
# 兼容无斜杠访问
|
|
|
|
|
|
location = /web {
|
|
|
|
|
|
return 302 /web/;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
location = /sys {
|
|
|
|
|
|
return 302 /sys/;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-22 13:34:10 +08:00
|
|
|
|
# 网页端(public/web/index.html -> dist/web/index.html)
|
|
|
|
|
|
location /web/ {
|
|
|
|
|
|
alias /usr/share/nginx/html/web/;
|
|
|
|
|
|
try_files $uri $uri/ /web/index.html;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 后台管理端(dist/index.html,前缀 /sys/)
|
|
|
|
|
|
location /sys/ {
|
|
|
|
|
|
alias /usr/share/nginx/html/;
|
|
|
|
|
|
try_files $uri $uri/ /sys/index.html;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-09 09:30:43 +08:00
|
|
|
|
# 其他任意路径统一兜底到网页端入口,避免出现 nginx 404 页面
|
2026-05-20 17:55:34 +08:00
|
|
|
|
location / {
|
2026-06-09 09:30:43 +08:00
|
|
|
|
try_files $uri $uri/ /web/index.html;
|
2026-05-20 17:55:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|