Skip to content

Instantly share code, notes, and snippets.

@jueti
Last active December 4, 2018 03:23
Show Gist options
  • Save jueti/548f625ad33c3cb5bc94fd98153dbf19 to your computer and use it in GitHub Desktop.
Save jueti/548f625ad33c3cb5bc94fd98153dbf19 to your computer and use it in GitHub Desktop.
[Nginx 禁用单个目录的目录索引] "/"开启目录索引,"/Chapter 3/"关闭目录索引,但可以访问目录下的文件 #nginx
server {
listen 80;
server_name localhost;
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~* ^.*\/$ {
root /usr/share/nginx/html;
autoindex on;
add_after_body /autoindex.html;
addition_types text/directory;
autoindex_exact_size off;
charset utf-8;
}
location = "/Chapter 3/" {
autoindex off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment