# Sidebar menu + directory listing

**URL:** <https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454>\
**Category:** NGINX\
**Created:** [November 13, 2013, 10:36pm UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454 "2013-11-13T22:36:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [November 13, 2013, 10:36pm UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/1 "2013-11-13T22:36:19Z")

</div>

Hi all,

I’d like to achieve the following, and found nothing so far trough  
research. Maybe someone could give me a pointer whether this is possible  
or not.

I’d like to use directory listing for some folders, which are made  
accessible trough a location directive. At the same time, it should be  
[sub.domain.com](http://sub.domain.com), I would like to create a sidebar menu (trough css or  
static html or whatever) to let users navigate trough a) some static  
html files and b) these specific folders, using directory listing. I  
hope this is understandable somehow…

Thanks,  
Georg

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 13, 2013, 10:46pm UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/2 "2013-11-13T22:46:16Z")

</div>

On 13 November 2013 21:35, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> html files and b) these specific folders, using directory listing. I  
> hope this is understandable somehow…

Looks to me like you want to use frames and write yourself some pretty  
basic HTML. I don’t know of anything that’s that application-a-like  
that comes /inside/ nginx itself, however.

Jonathan

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 13, 2013, 10:57pm UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/3 "2013-11-13T22:57:22Z")

</div>

Hi,

On 13-11-13 21:45:46, Jonathan M. wrote:

> On 13 November 2013 21:35, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
> Looks to me like you want to use frames and write yourself some pretty  
> basic HTML. I don’t know of anything that’s that application-a-like  
> that comes /inside/ nginx itself, however.

Yeah, I tought so aswell. My question was more like “how do I combine  
html and directory listing at the same time…”?

Thanks,  
Georg

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 13, 2013, 11:09pm UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/4 "2013-11-13T23:09:38Z")

</div>

Quite simply make all locations that are to listed use the autoindex on;  
directive.

If I understood correctly you want all vhosts of the form sub.domain.tld  
be  
listed. So just make the “catch all” location / use the autoindex  
directive.  
Le 13 nov. 2013 22:57, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) a crit :

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 13, 2013, 11:52pm UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/5 "2013-11-13T23:52:52Z")

</div>

Hi,

Sorry, maybe I’m dumb, I’m not sure if I get it…

On 13-11-13 22:09:40, Francis D. wrote:

> the content that you would like to have returned?  
> For the directory tree, you mean something like:

root  
|- index.html (should be displayed as html)  
|- n.html (should be displayed as html)  
|- dir1 (should be displayed via directory listing)  
|- dir2 (should be displayed via directory listing)

sidebar should look like:

Index (should point to index.html)  
n (should point to n.html)  
dir1 (should point to dir1)  
dir2 (should point to dir2)

> For directory listings, do a manual “ls” (or whatever) once to hard-code  
> the html.

Doing “ls” where? Inside the html?

> That exercise might make clear to you what content you want nginx to  
> return in response to different requests – particularly, which parts  
> are static and which parts are dynamic. And that in turn might help you  
> decide whether you want an nginx module, or the plain directory handler,  
> or something like an index.php that you can drop in each directory.

Still unclear to me how I display html and directory listing at the same  
tome on the “same page”.

> (I you use frames, you will be making more than one http request, so  
> nginx will be able to return more than one piece of content.)

If possible, I would like to avoid frames.

> Good luck with it,

Thanks,  
Georg

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 14, 2013, 12:32am UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/6 "2013-11-14T00:32:37Z")

</div>

On Wed, Nov 13, 2013 at 11:52:05PM +0100, removed\_email\_address@domain.invalid wrote:

> On 13-11-13 22:09:40, Francis D. wrote:
> 
> > On Wed, Nov 13, 2013 at 10:56:28PM +0100, removed\_email\_address@domain.invalid wrote:

Hi there,

> Sorry, maybe I’m dumb, I’m not sure if I get it…

I’m trying to suggest that you do the background not-nginx-related  
preparation work for your question outside of nginx, so that you have  
a very clear idea of what you want nginx to do, and can then describe  
clearly what that is.

> > Can you build a small directory tree, and manually create the files with  
> > the content that you would like to have returned?
> 
> For the directory tree, you mean something like:
> 
> root  
> |- index.html (should be displayed as html)  
> |- n.html (should be displayed as html)  
> |- dir1 (should be displayed via directory listing)  
> |- dir2 (should be displayed via directory listing)

So, on the file system you have two files and two directories.

Presumably your web browser is going to make http requests for things  
like “/” and “/index.html” and “/dir1/”; and you want nginx to return  
specific content for each request.

> sidebar should look like:
> 
> Index (should point to index.html)  
> n (should point to n.html)  
> dir1 (should point to dir1)  
> dir2 (should point to dir2)

This part, I don’t understand.

I suggest you do whatever it takes to manually create the html or  
javascript or whatever you want, and put it in a file, so that when  
your browser asks for that file, you see exactly what you want to see  
on-screen.

Do this manually, for just this one example directory. Don’t worry about  
any part of it being dynamically generated. That comes later.

> > For directory listings, do a manual “ls” (or whatever) once to hard-code  
> > the html.
> 
> Doing “ls” where? Inside the html?

When you are manually creating the one-off static page that shows  
exactly what you want, it will include mention of all nearby files  
and directories.

Do whatever it takes – possibly including “ls” – to hard-code the  
html-or-javascript that you want to see.

> Still unclear to me how I display html and directory listing at the same  
> tome on the “same page”.

Do a static one-off test first.

After that, you will have a much better idea of which parts you want to  
be static and which parts you want to be dynamic.

And then your question might become “how do I change the ‘autoindex’  
output to be _this_ instead of _that_?”; or it might become “how do I  
get an ‘index’ file to generate output like _this_?”; or it might become  
something else specific.

Right now, all I can understand of your question is “can nginx do what  
I want?”.

Maybe your question is already clear enough to other people, in which  
case maybe they can offer suggestions.

## f

Francis D. removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 14, 2013, 12:40am UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/7 "2013-11-14T00:40:12Z")

</div>

On 13-11-13 23:52:05, removed\_email\_address@domain.invalid wrote:

> On 13-11-13 22:09:40, Francis D. wrote:
> 
> > On Wed, Nov 13, 2013 at 10:56:28PM +0100, removed\_email\_address@domain.invalid wrote:
> > 
> > > On 13-11-13 21:45:46, Jonathan M. wrote:  
> > > For directory listings, do a manual “ls” (or whatever) once to hard-code  
> > > the html.
> 
> Doing “ls” where? Inside the html?

…maybe I’ll just write a small script using tree -H to output a  
directory listing into static html, and serve this just as html.  
Clever doing it like this?

Cheers,  
Georg

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 14, 2013, 9:09am UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/8 "2013-11-14T09:09:35Z")

</div>

## removed\_email\_address@domain.invalid Wrote:

> …maybe I’ll just write a small script using tree -H to output a  
> directory listing into static html, and serve this just as html.  
> Clever doing it like this?

> **[Fancy Index | NGINX](https://www.nginx.com/resources/wiki/modules/fancy_index/)**
>
> The Fancy Index module makes possible the generation of file listings like the built-in autoindex module does, but adds a touch of style.

Posted at Nginx Forum:

> **[Re: sidebar menu + directory listing](https://forum.nginx.org/read.php?2,244638,244653#msg-244653)**
>
> Hi all, I'd like to achieve the following, and found nothing so far trough research. Maybe someone could give me a pointer whether this is possible or not. I'd like to use directory listing for some folders, which are made accessible trough a...

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 13, 2013, 11:10pm UTC](https://www.ruby-forum.com/t/sidebar-menu-directory-listing/237454/9 "2013-11-13T23:10:13Z")

</div>

On Wed, Nov 13, 2013 at 10:56:28PM +0100, removed\_email\_address@domain.invalid wrote:

> On 13-11-13 21:45:46, Jonathan M. wrote:
> 
> > On 13 November 2013 21:35, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Hi there,

> > Looks to me like you want to use frames and write yourself some pretty  
> > basic HTML. I don’t know of anything that’s that application-a-like  
> > that comes /inside/ nginx itself, however.
> 
> Yeah, I tought so aswell. My question was more like “how do I combine  
> html and directory listing at the same time…”?

Can you build a small directory tree, and manually create the files with  
the content that you would like to have returned?

For directory listings, do a manual “ls” (or whatever) once to hard-code  
the html.

That exercise might make clear to you what content you want nginx to  
return in response to different requests – particularly, which parts  
are static and which parts are dynamic. And that in turn might help you  
decide whether you want an nginx module, or the plain directory handler,  
or something like an index.php that you can drop in each directory.

(I you use frames, you will be making more than one http request, so  
nginx will be able to return more than one piece of content.)

Good luck with it,

## f

Francis D. removed\_email\_address@domain.invalid
