最新消息:20210917 已从crifan.com换到crifan.org

【已解决】crifan.org网站开启目录列表显示

crifan.org crifan 1882浏览 0评论

之前访问

https://www.crifan.org/files/doc/docbook/

都是不允许访问,无法访问

而换chrome,虽然是 404跳转到主页了

但是还是无法访问

希望能以目录列表显示

希望可以设置nginx,允许访问,且其子目录,也可以访问

nginx folder listing

Enable directory listing – Nginx Library

Enabling the Nginx Directory Index Listing – KeyCDN Support

How to configure nginx to enable kinda ‘file browser’ mode? – Stack Overflow

Show only some files in directory listing with NGINX – Stack Overflow

Module ngx_http_autoindex_module

[root@crifan ~]# nginx -t
nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful

找到配置文件是:

[root@crifan vhost]# pwd
/usr/local/tengine/conf/vhost
[root@crifan vhost]# ll 
total 8
-rw-r--r-- 1 root root 1374 May 23 21:34 book.crifan.org.conf
-rw-r--r-- 1 root root 1385 May 23 22:22 www.crifan.org.conf

然后去编辑:

vim www.crifan.org.conf

然后去加上:

  location /files/doc/docbook/ {
    autoindex on;
    autoindex_exact_size off;
    autoindex_format html;
    autoindex_localtime on; 
  }

reload以生效:

[root@crifan vhost]# service nginx reload
Redirecting to /bin/systemctl reload nginx.service

去打开:

https://www.crifan.org/files/doc/docbook/

果然可以了:

要继续确认子目录是否可以以目录访问

https://www.crifan.org/files/doc/docbook/antlr_tutorial/

https://www.crifan.org/files/doc/docbook/antlr_tutorial/release/html/

嗯,子目录也是可以的文件列表的,和显示文件大小的。

另外目录:

https://book.crifan.org/books

中现在也是无法访问

也去加上配置允许目录列表

去编辑:

vi book.crifan.org.conf

加上:

  location /books/ {
    autoindex on;
    autoindex_exact_size off;
    autoindex_format html;
    autoindex_localtime on; 
  }

去:

service nginx reload 

同理子目录也可以访问:

https://book.crifan.org/books/gitbook_demo/

然后website,由于有index.html,正常显示页面:

前言 · Gitbook演示

【总结】

通过:

nginx -t

找到配置文件路径是:

# pwd
/usr/local/tengine/conf/vhost

其中有:

# ll
total 8
-rw-r--r-- 1 root root 1503 Jun 23 15:59 book.crifan.org.conf
-rw-r--r-- 1 root root 1526 Jun 23 15:44 www.crifan.org.conf

然后去编辑:

vi book.crifan.org.conf

加上:

  location /books/ {
    autoindex on;
    autoindex_exact_size off;
    autoindex_format html;
    autoindex_localtime on; 
  }

编辑:

vi www.crifan.org.conf

加上:

  location /files/doc/docbook/ {
    autoindex on;
    autoindex_exact_size off;
    autoindex_format html;
    autoindex_localtime on; 
  }

然后reload生效:

service nginx reload

即可:

使得:

https://www.crifan.org/files/doc/docbook/

https://book.crifan.org/books

可以目录列表访问,以及其下各级子目录都可以目录访问。

转载请注明:在路上 » 【已解决】crifan.org网站开启目录列表显示

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
94 queries in 0.189 seconds, using 23.33MB memory