fix(5):调整nginx配置,解决仅能通过根目录访问的问题

This commit is contained in:
2025-08-05 14:37:40 +08:00
parent 2bdf71cf7a
commit 54dd8b2a2d
2 changed files with 24 additions and 0 deletions
+3
View File
@@ -4,4 +4,7 @@ FROM nginx:alpine
RUN apk add --no-cache curl RUN apk add --no-cache curl
COPY dist/ /usr/share/nginx/html/ COPY dist/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80 EXPOSE 80
+21
View File
@@ -0,0 +1,21 @@
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html; # 关键配置
}
# 可选:健康检查路径(如果有)
location /health {
access_log off;
return 200 'healthy';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}