Installing Fancy Index Module on Nginx
First, get the Nginx source code. The version must
match exactly what we have on the system.
nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
wget https://nginx.org/download/nginx-1.18.0.tar.gz
tar xzvf nginx-1.18.0.tar.gz
Then get the Fancy Index module.
git clone https://github.com/aperezdc/ngx-fancyindex.git
We need to configure Nginx with exact arguments as
what we have. Run
nginx -V
to get
the arguments. Then, run the following:cd nginx-1.18.0
./configure [... args from nginx -V] --add-dynamic-module=../ngx-fancyindex
Depending on the system configuration, it may fail
several times. I needed to install the following in order to succeed. You
may need to install a different set of modules.
sudo apt install -y libpcre3-dev libxslt-dev libgd-dev libgeoip-dev
After the
configure
completes without errors, run
the following:make modules
It will generate
*.so
files in the objs
folder. Copy our newly built module
to our Nginx installation folder:sudo cp objs/ngx_http_fancyindex_module.so /usr/share/nginx/modules
Lastly, add the following in
/etc/nginx/nginx.conf
load_module /usr/share/nginx/modules/ngx_http_fancyindex_module.so;
Now, we can use
fancyindex
directives on our sites.
Replace autoindex
directives with
fancyindex
.server {
server_name files.azaky.io;
location / {
# autoindex on;
fancyindex on;
fancyindex_exact_size off;
}
}
Reload Nginx with our latest configuration.
sudo nginx -t
sudo nginx -s reload
Reference: