美文网首页nginx
3-nginx配置多个前端项目

3-nginx配置多个前端项目

作者: Guoyubo | 来源:发表于2018-11-27 17:00 被阅读0次

    目的:

    实现通过域名+项目名的方式访问不同前端项目

    前提:

    前端项目路径/front_page/infographic,这个里面直接是index文件


    图片.png

    nginx配置

    用了root 和alias两种方式

           location / {
                root   /usr/share/nginx/html;
                index  index.html index.htm;
            }
    
    #前端测试alias !!!!!!!!!!
            #location /infographic {
        #       alias /front_page/infographic/;
          #         index  index.html index.htm; 
         #   }
    #前端测试root !!!!!!!!!
        location /infographic {
                   root /front_page;
                   index  index.html index.htm;
    
            }
    
    

    区别

    root配置 :nginx直接转发至 root后面地址+location 后面地址
    alias配置: nginx直接转发至 alias的地址,不会加上location后的内容
    alias配置最后一定要 “/” 结尾 ,root随意

    相关文章

      网友评论

        本文标题:3-nginx配置多个前端项目

        本文链接:https://www.haomeiwen.com/subject/hsfnqqtx.html