解决前端部署到Nginx非根目录下页面出现空白的问题

问题:

     最近前端vue项目迁移至K8S容器中,因在Nginx非根目录下页面下出现空白的问题

现象:    前端系统页面空白,只有标题栏

nginx容器默认配置:
location / {
     root /usr/share/nginx/html;
     try_files $uri /index.html;
}

解决:
出处:https://www.cnblogs.com/liucx/


在容器中修改nginx配置
location / {
     root /usr/share/nginx/html;
    return 200;
}
#新增
location /test{
    alias /usr/share/nginx/html;
    try_files $uri /test/index.html;
}

希望对您有所帮助

原文地址:https://www.cnblogs.com/liucx/p/14189432.html