在服务器用nginx运行自己的项目

139 阅读1分钟

在服务器用nginx运行自己的项目

    location / {
   root /nginx/project2/dist;
   index index.html;
   try_files $uri $uri/ @router;
  }
​
  #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
  location @router {
  #   #因此需要rewrite到index.html中,然后交给路由再处理请求资源
     rewrite ^.*$ /index.html last;
  }
​
  location /shop {
   alias /nginx/project1/dist;
   index index.html index.htm;
   try_files $uri $uri/ @router;
   index index.html;
  }
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的
  location @router {
  #   #因此需要rewrite到index.html中,然后交给路由再处理请求资源
   try_files $uri $uri/ @router;
   index index.html;
  }
  
    #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体>的文件
  location @router {
  #   #因此需要rewrite到index.html中,然后交给路由再处理请求资源
    rewrite ^.*$ /index.html last;
  }
    
    location /echarts {
   alias /nginx/project3/dist;
   index index.html index.htm;
   try_files $uri $uri/ @router;
   index index.html;
  }

\