nginx部署前端项目的配置

73 阅读1分钟
配置文件如下

主要是 '/项目名'这种配置的情况下需要用alias

    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location / {
            root   html/dist;
            index  index.html index.htm;
        }
        # alias==================用root的话会404.看下error日志就知道了
        location /datav {
            alias   html/datav/dist;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }