Nginx( openresty ) 设置首页 跳转 与默认地址 访问 思路处理

1.访问页面时 html 缺少了个 l 导致跳转后台登录页面
处理方案 在nginx.conf 中添加一下配置 以下方法只能使用在小规模网站
# 首页设置 index.html index.htm 访问时 返回对应的index.html 内容
location ~* ^.+index.(html|htm){
alias /opt/index.html; # 对应页面 存放的index.html位置
}

  1. 由于使用了vue 与 负载均衡
    所以会在nginx 中匹配 location /{}
    改方法中将一些路径 处理首页 根路径 "/"
    location / {
    # 匹配根路径 返回首页
    if ( $request_uri = "/" ){
    rewrite "/" /index.html break;
    }

               # 负载均衡
               if (-f $request_filename){
                     proxy_pass http://server;
                     break;
               }     
         
         }
    

由于后台 使用了vue 与 tomcat负载 ,并且没有区分对应tomcat 的路径 所以vue 中不能使用 mode:'history' 模式 否则会直接跳转到后台的权限中


    吾之爱,心之念。
           携子手,到白头。

原文地址:https://www.cnblogs.com/JC-0527/p/13356568.html