【问题标题】:Nginx error 404 when using autoindex使用自动索引时 Nginx 错误 404
【发布时间】:2017-12-01 17:37:14
【问题描述】:

我对 nginx 完全陌生。我已经在 windows pc 上安装了 nginx。

我想要做的是将D:\ 中的文件列表提供给localhost:8082/list

如果我使用以下配置:

server {
    listen       8082;

    location / {
        root D:/;
        autoindex on;
    }
}

我可以在localhost:8082 上正确看到我想要的内容。但是,如果我将其更改为:

server {
    listen       8082;

    location /list {
        root D:/;
        autoindex on;
    }
}

localhost:8082/list 页面出现 404 错误。

【问题讨论】:

    标签: nginx nginx-location


    【解决方案1】:

    您需要的是alias 而不是root

    server {
        listen       8082;
    
        location /list {
            alias D:/; ##### use alias, not root
            autoindex on;
        }
    }
    

    Nginx -- static file serving confusion with root & alias

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 2021-07-20
      • 2014-08-01
      • 2017-09-24
      • 2023-04-03
      • 1970-01-01
      相关资源
      最近更新 更多