美文网首页
nginx中一个server配置多个location

nginx中一个server配置多个location

作者: zhihaoZzz | 来源:发表于2024-05-05 10:31 被阅读0次
  • 配置多个站点,配置多个location
server {
        listen       80;
       location /spring {
            root /data_prod/webapp/spring;
            index index.html;
        }
        location / {
            root /data_prod/webapp/lamp-web-pro-datasource/dist;
            index index.html;
        }
}

配置完以后访问。http://xxxx/spring提示404

  • 将具有具体路径的站点,将root修改为使用alias配置
server {
        listen       80;
       location /spring {
            alias /data_prod/webapp/spring;
            index index.html;
        }
        location / {
            root /data_prod/webapp/lamp-web-pro-datasource/dist;
            index index.html;
        }

}

改动后即可以使用了;

相关文章

网友评论

      本文标题:nginx中一个server配置多个location

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