nginx目录列表和目录访问权限设置
2014-08-03 08:42
253 查看
1.目录列表(directory listing)
nginx让目录中的文件以列表的形式展现只需要一条指令这样就不会返回403
autoindex on;
autoindex可以放在location中,只对当前location的目录起作用。你也可以将它放在server指令块则对整个站点都起作用。或者放到http指令块,则对所有站点都生效。
下面是一个简单的例子:
server {
listen 80;
server_name domain.com www.domain.com;
access_log /var/...........................;
root /var/www/html;
location / {
index index.php index.html index.htm;
}
location /api {
autoindex on;
}
}
2.nginx禁止访问某个目录
跟Apache的Deny from all类似,nginx有deny all指令来实现。
禁止对叫dirdeny目录的访问并返回403 Forbidden,可以使用下面的配置:
location /dirdeny {
deny all;
return 403;
}
nginx让目录中的文件以列表的形式展现只需要一条指令这样就不会返回403
autoindex on;
autoindex可以放在location中,只对当前location的目录起作用。你也可以将它放在server指令块则对整个站点都起作用。或者放到http指令块,则对所有站点都生效。
下面是一个简单的例子:
server {
listen 80;
server_name domain.com www.domain.com;
access_log /var/...........................;
root /var/www/html;
location / {
index index.php index.html index.htm;
}
location /api {
autoindex on;
}
}
2.nginx禁止访问某个目录
跟Apache的Deny from all类似,nginx有deny all指令来实现。
禁止对叫dirdeny目录的访问并返回403 Forbidden,可以使用下面的配置:
location /dirdeny {
deny all;
return 403;
}
autoindex_exact_size off;//人性化方式显示文件大小否则以byte显示 autoindex_localtime on;//按服务器时间显示,否则以gmt时间显示,gmt时间指格林尼治时间 autoindex_exact_size off; 默认为on,显示出文件的确切大小,单位是bytes。 改为off后,显示出文件的大概大小,单位是kB或者MB或者GB autoindex_localtime on; 默认为off,显示的文件时间为GMT时间。 改为on后,显示的文件时间为文件的服务器时间
相关文章推荐
- nginx目录列表和目录访问权限设置
- nginx目录列表和目录访问权限设置
- nginx目录列表和目录访问权限设置
- nginx目录列表和目录访问权限设置
- nginx配置目录列表访问权限
- nginx设置目录文档访问权限
- 如何设置Apache禁止访问目录(列出目录/文件列表)
- nginx设置上传目录无执行权限
- Forms安全认证 设置不同目录权限访问
- Apache和Nginx下文件和目录禁止访问安全设置
- Apache下子目录访问权限的设置
- apache,nginx上传目录无执行权限的设置方法
- Linux文件和目录访问权限设置
- Linux文件和目录访问权限设置
- Fedora-Linux文件和目录访问权限设置
- 设置Windows系统NTFS某个目录的用户访问权限(c#)
- apache,nginx上传目录无执行权限的设置方法
- nginx设置目录访问密码
- 文件和目录访问权限设置
- Linux文件和目录访问权限设置