nginx代理多前端个项目 关于root使用方法

1.root 设置

nginx代理多前端个项目 关于root使用方法_第1张图片

端口号8090

假如我们现在要代理2个项目
1.第一个开头是要·localhost:8090/abc 开头项目
2.第二个开头是要 localhost:8090/efg 开头项目

  • 第一个项目nginx配置
      location /abc  {
            root   E:/web/project/dist;
            index  index.html;
            try_files $uri $uri/ /index.html;
        }

实际上的文件夹路径是 E:/web/project/dist/abc;你的项目全部东西要放到abc里面·包括html

  • 同理第二个项目配置
      location /efg  {
            root   E:/web/project/dist;
            index  index.html;
            try_files $uri $uri/ /index.html;
        }

实际上的文件夹路径是 E:/web/project/dist/efg;你的项目全部东西要放到efg里面·包括html

  • 除了代理html还可以代理其他东西包括图片,视频,其他文件等
      location /image  {
            root   E:/develop/webProject/vueProject;
        }

服务器目录nginx代理多前端个项目 关于root使用方法_第2张图片
浏览器打开localhost:8090/image/1.png
nginx代理多前端个项目 关于root使用方法_第3张图片
浏览器打开localhost:8090/image/bi.zip 就会自动下载

你可能感兴趣的:(搭建项目,nginx)