访问静态资源是一个Web服务器最简单的需求,Nginx中配置静态资源非常简单。
下面是默认配置文件中,server中的location配置:
server
location
location / { root html; index index.html index.htm; }
在配置中添加autoindex on;,可以开启显示文件夹中的文件列表功能,该功能常用于类似文件分享服务器的场景。
autoindex on;