Fancyindex

From XPUB & Lens-Based wiki
Revision as of 19:11, 13 September 2019 by )biyibiyibiyi( (talk | contribs)

what is FancyIndex?

The Fancy Index module makes possible the generation of file listings, like the built-in autoindex module does. It provides more potentials than autoindex module which also generates file listing, but possible to alternate CSS qualities of the page. Such as:

  1. custom headers
  2. custom footers
  3. own css stylesheet
  4. Allow choosing to sort elements by name (default), modification time, or size; both ascending (default), or descending (new in 0.3.3). (which I haven't tried out, yet. what is this function?)

implementation

  1. install nginx on server, I am running a raspberry pi server with Raspian lite.
  2. download and install package nginx extras with following command
     sudo apt-get install nginx-extras 
  3. after download, edit with text editor the following nginx configuration file in
     /etc/nginx/sites-available/default 
    with following configurations.
  4. in server directive, find a directive named location, add the FancyIndex configuration:
location / { fancyindex on; # Enable fancy indexes.
fancyindex_exact_size off;  # Output human-readable file sizes.
} 

afterwards restart nginx by entering

 sudo service nginx restart 

check if the configuration file is updated correctly by entering if nginx fails to restart.

 systemctl status nginx.service 

enable several directories and disabling directories

For example, I would like to enable my main directory, however inside the main directory, there is a directory I would not want to apply directory listing.

The location directive can allow this as it includes the location path.

Note that the configuration file specified root directory as /var/www/html, so the path entered is relative to that.

For example to enable entire directory, enter in the configuration file in location the root path as /

location / {

fancyindex on;
fancyindex_exact_size off;
}

in a parallel location directory can specify for another path, for example to disable fancyindex for a folder within root:

location /about {

fancyindex off;              # disable fancy indexes.