Nginx - zhongjiajie/zhongjiajie.github.com GitHub Wiki

Nginx

FAQ

访问静态文件/文件夹

如果nginx服务器下面有静态文件需要访问,应该怎么配置

  • 按照文件夹配置

    server {
        location ^~ /PATH/TO/FOLDER {
            root /home/www/;
        }
    }
  • 按照文件后缀配置

    server {
        location ~ \.(txt|json)$ {
            root /home/www/;
        }
    }

查看文件列表

增加autoindex为on的配置

location / {
   root                 /home/yozloy/html/;
   index                index.html;
   autoindex            on;
   autoindex_exact_size on;
   autoindex_localtime  on;
}
⚠️ **GitHub.com Fallback** ⚠️