nginx一个server配置多个location出现404

46 阅读1分钟

问题描述

配置多个站点404
我选择了配置多个location。



server {
    listen 80;
    server_name www.bpmnmoderler.com;
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

    location / {
       root   /home/web/bpmn-modeler/dist;
       index index.html index.htm;
    }

    location /flowable {
       root   /home/web/bpmn-modeler/flowable;
       index index.html index.htm;
    }

}

配置完以后访问。www.bpmnmoderler.com/flowable 提示404
找了好久才搞明白, location如果一个特定的url 要使用别名,不能用root,alias指定的目录是准确的,root是指定目录的上级目录,改动后即可以使用了

server {
    listen 80;
    server_name www.bpmnmoderler.com;
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

    location / {
       root   /home/web/bpmn-modeler/dist;
       index index.html index.htm;
    }

    location /flowable {
       root   /home/web/bpmn-modeler/flowable;
       index index.html index.htm;
    }

}

此时访问www.bpmnmoderler.com/flowable 可以正常访问啦。