# Autoindex module extension

**URL:** <https://www.ruby-forum.com/t/autoindex-module-extension/216496>\
**Category:** NGINX\
**Created:** [February 6, 2012, 5:17pm UTC](https://www.ruby-forum.com/t/autoindex-module-extension/216496 "2012-02-06T17:17:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 6, 2012, 5:17pm UTC](https://www.ruby-forum.com/t/autoindex-module-extension/216496/1 "2012-02-06T17:17:07Z")

</div>

Hello,

I have written an extension for the Autoindex module that adds  
two new directives. I’ve included the patch against the latest  
1.1.14 version of nginx, as well as the documentation for the  
Wiki.

Max

autoindex\_omit\_index\_of  
syntax: autoindex\_omit\_index\_of [on|off]  
default: off  
context: http, server, location  
variables: no  
version: \>= 1.1.14

This directive determines whether the "Index of " string is displayed  
in the title and in the header of a directory listing. It takes one  
argument (a boolean flag), and is set to off by default, so "Index of "  
is displayed as usual.

autoindex\_dirname\_to\_display  
syntax: autoindex\_dirname\_to\_display \<directory\_name\_string\>;  
default: none  
context: http, server, location

This directive determines the directory name to display next  
to the "Index of " string in the title and in the header of a  
directory listing. It takes one argument (a string), which can  
contain variables. This directive can also be used to remove  
trailing slashes from a directory pathname.

location ~ ^/internal/([^/]+)(|/.\*)$ {  
internal;  
set $dir “$1 :: $2”;  
autoindex on;  
autoindex\_omit\_index\_of on;  
autoindex\_dirname\_to\_display “-==[NGiNX & Co :: $dir]==-”;  
alias /mnt/nfs/server123/$1/$2;  
}

The example above demonstrates how to display the directory contents  
of /mnt/nfs/server123/$1/$2 while omitting the "Index of " string,  
and displaying the following customized string instead of the  
“Index of /internal/$1/$2/” string in the title and in the header  
of the directory listing:

“-==[NGiNX & Co :: $1 :: $2]==-”

location ~ ^/internal/~([^/]+)/(|.\*)$ {  
internal;  
autoindex on;  
autoindex\_dirname\_to\_display “nfs:/home/$1/public\_html/$2”;  
alias /mnt/nfs/server123/$1/$2;  
}

The example above demonstrates how to display the directory contents  
of /mnt/nfs/server123/$1/$2 using the following customized string  
instead of the “Index of /internal/~$1/$2” string in the title and  
in the header of the directory listing:

“Index of nfs:/home/directory/$1/public\_html/$2”

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [February 6, 2012, 6:01pm UTC](https://www.ruby-forum.com/t/autoindex-module-extension/216496/2 "2012-02-06T18:01:12Z")

</div>

Hello!

On Mon, Feb 06, 2012 at 08:15:59PM +0400, Max wrote:

> Hello,
> 
> I have written an extension for the Autoindex module that adds  
> two new directives. I’ve included the patch against the latest  
> 1.1.14 version of nginx, as well as the documentation for the  
> Wiki.

There are no plans to extend autoindex with various  
customizations. Instead, we’ll likely provide xml index to make  
arbitrary customization via xslt possible.

Maxim D.

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [February 7, 2012, 10:50pm UTC](https://www.ruby-forum.com/t/autoindex-module-extension/216496/3 "2012-02-07T22:50:19Z")

</div>

06 февраля 2012, 21:00 от Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> On Mon, Feb 06, 2012 at 08:15:59PM +0400, Max wrote:
> 
> > I have written an extension for the Autoindex module that adds  
> > two new directives. I’ve included the patch against the latest  
> > 1.1.14 version of nginx, as well as the documentation for the  
> > Wiki.
> 
> There are no plans to extend autoindex with various  
> customizations. Instead, we’ll likely provide xml index to make  
> arbitrary customization via xslt possible.

Then could you maybe add my extension to the list of 3rd party  
modules and patches?

You can find the patch and the documentation here:

NGiNXYZ NGiNX Autoindex Module Extension  
[http://nginxyzpro.berlios.de/nginxyz\_nginx\_autoindex\_module\_extension/](http://nginxyzpro.berlios.de/nginxyz_nginx_autoindex_module_extension/)

Max

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [February 8, 2012, 6:50am UTC](https://www.ruby-forum.com/t/autoindex-module-extension/216496/4 "2012-02-08T06:50:14Z")

</div>

08 февраля 2012, 04:31 от Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > arbitrary customization via xslt possible.  
> > > may update yourself if you feel it’s usable for others.  
> > > I have updated the wiki to include my extension:  
> > > [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/3rdPartyModules#Third_party_patches)

> (You may also want to look at fancy index 3rd party module, which is  
> expected to cover most of customization needs as of now. See  
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NgxFancyIndex.))

I’m familiar with that module, but it doesn’t provide the features  
my extension provides, which is why I wrote my extension.  
While the fancy\_index\_header directive could be used to include  
a customized header file to omit the “Index of” string in the title  
and in the header (which is what my autoindex\_omit\_index\_of  
directive does), there is no way to customize the displayed  
directory name with the fancy index module, it always displays  
the URI, unlike my autoindex\_dirname\_to\_display directive, which  
can be set to display anything, including variables, instead of  
the standard URI-based “Index of /directory/subdirectory/” string.

Max

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [February 8, 2012, 1:31am UTC](https://www.ruby-forum.com/t/autoindex-module-extension/216496/5 "2012-02-08T01:31:20Z")

</div>

Hello!

On Wed, Feb 08, 2012 at 01:49:39AM +0400, Max wrote:

> > arbitrary customization via xslt possible.
> 
> Then could you maybe add my extension to the list of 3rd party  
> modules and patches?
> 
> You can find the patch and the documentation here:
> 
> NGiNXYZ NGiNX Autoindex Module Extension  
> [http://nginxyzpro.berlios.de/nginxyz\_nginx\_autoindex\_module\_extension/](http://nginxyzpro.berlios.de/nginxyz_nginx_autoindex_module_extension/)

The only list of 3rd party modules we have is in wiki, which you  
may update yourself if you feel it’s usable for others.

(You may also want to look at fancy index 3rd party module, which is  
expected to cover most of customization needs as of now. See  
[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NgxFancyIndex.))

Maxim D.
