How to configure nginx to enable kinda 'file browser' mode?

前端 未结 6 924
眼角桃花
眼角桃花 2020-12-07 14:48

Once I\'ve seen this before when I type a URL http://test.com/test/, instead of give me a html page, it gives me a \'file browser\' like interface to browse all

6条回答
  •  萌比男神i
    2020-12-07 14:58

    You should try HttpAutoindexModule.

    Set autoindex option to on. It is off by default.

    Your example configuration should be ok

    location /{ 
       root /home/yozloy/html/; 
       index index.html; 
       autoindex on;
    }
    

    Without autoindex option you should be getting Error 403 for requests that end with / on directories that do not have an index.html file. With this option you should be getting a simple listing:

    
    Index of /
    
    

    Index of /test/


    ../
    test.txt                 19-May-2012 10:43            0
    

    Edit: Updated the listing to delete any references to test

提交回复
热议问题