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

前端 未结 6 931
眼角桃花
眼角桃花 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条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 15:11

    1. List content of all directories

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

    Your configuration file ( vi /etc/nginx/sites-available/default ) should be like this

    location /{ 
       ... ( some other lines )
       autoindex on;
       ... ( some other lines )
    }
    

    2. List content of only some specific directory

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

    Your configuration file ( vi /etc/nginx/sites-available/default )
    should be like this.
    change path_of_your_directory to your directory path

    location /path_of_your_directory{ 
       ... ( some other lines )
       autoindex on;
       ... ( some other lines )
    }
    

    Hope it helps..

提交回复
热议问题