server { listen 80; server_name localhost; location /mobile { # 关键配置:指向构建产物的物理路径 alias /usr/share/nginx/html/mobile; # 处理Vue路由的HTML5 History模式 try_files $uri $uri/ /mobile/index.html; # 确保正确识别文件类型 types { text/html html; application/javascript js; text/css css; } } # 可选:重定向根路径到/mobile(按需启用) # location = / { # return 301 /mobile; # } }