Phoenix controller for directory listing of statically-served files?

I am looking for a controller which can perform directory listing of an absolute path ( = not in the default priv/static folder path) of static file directories, such as the autoindex option of nginx or “Options Indexes” in Apache. I’d appreciate if anyone let me know the URL for a package for this purpose is available.

Tried searching on Hex (“directory listing”, “plug directory”, “plug files”, etc.) but nothing came up. Might be an interesting exercise though if someone wants to implement it (I imagine by using among other things). I found that Node.js has one such package (serve-index).

Then again, is there any reason for not using nginx?

Thx @bobbypriambodo - I’m actually using yaws for daily tasks which needs the directory listings (to view build logs of FreeBSD test tool called Poudriere). I am trying to write an equivalent server with Phoenix, and I stumbled. It will surely be a good experiment to implement the controller.

BTW thx also for the info of serve-index of npm.

Modifying the Plug.Static to serve directory listing looks promising. WIP repository:

1 Like

Looks nice! I agree that exposing directory listings might expose some nasty vulnerabilities, but if you take good care of which paths you expose I think it can be circumvented.

A note on the module name, I’m not sure putting it under Plug.Static namespace is a good idea… I named my package Phoenix.Token.Plug back then and Chris asked me to change it, because I think the convention in Elixir is to not stomp on each other’s namespaces :slight_smile: I don’t know if that applies to yours, but in case it does, probably you can use PlugStatic.Ls or PlugStaticLs?


The module name is now changed to PlugStaticLs since v0.2.0 to avoid conflict with Plug modules. Thanks for suggestion.

Doing proper access restriction will minimize the risk of directory path traversal.

1 Like

FYI: plug_static_ls is on Hex as


Update to v0.6.1 if you use plug_static_ls: the code is upgraded reflecting the recent vulnerability fix of Plug.Static.