Skip to content
Nuno Luciano edited this page Jun 4, 2024 · 6 revisions

Welcome to the server-directory-index wiki!

What is h5ai

A quote from the official website.

h5ai is a modern file indexer for HTTP web servers with focus on your files. Directories are displayed in a appealing way and browsing them is enhanced by different views, a breadcrumb and a tree overview. Initially h5ai was an acronym for HTML5 Apache Index but now it supports other web servers too.

Overview

The initial goal was to share a server in the local network and facilitate quick access to archives and other public files, easily downloadable from any browser, without being forced to connect. The update integrates features from forks of h5ai, with no installation required, just a configuration file. Here are some of the features:

  • breadcrumbs, tool bar
  • auto refresh
  • custom header and footer for each directory
  • select and download multiple files and folders
  • filter function for files and folders
  • folder size
  • localization
  • ui view density
  • tree view
  • display details
  • preview audio, image, code, video, pdf
  • QR codes on hovering files
  • thumbnails for images, pdfs and movies

These are some awesome features to improve the web server directory index!
Most options can be customized in /private/conf/config.json, more on that later.

Usage

Unpack server directory index h5ai to your /www/public/*.*
and access your domain/public

Whatever you drop on the Public folder will automatically
be available on the web server and you can easily share the links.

Remote Server

  1. Download server directory index h5ai
  2. Open WinSCP or FileZilla or any SFTP client
  3. Upload the files

Server Index redirection

Add the public directory index to your server configuration.
You can also redirect every access to the /public/ directory.

Apache httpd 2.2/2.4

In the root directory's .htaccess file add:

DirectoryIndex  index.html  index.php  /_h5ai/public/index.php

In httpd.conf add:

<Directory /var/www/public/>
	DirectoryIndex index.html index.php /_h5ai/server/php/index.php
</Directory>

PDF.js requires Apache to serve .mjs modules files.
Add the mime type to the .htaccess file in your root directory where index.html can be accessed:

<IfModule mod_mime.c>
  AddType text/javascript js mjs
</IfModule>

Lighttpd 1.4

In lighttpd.conf add:

index-file.names += ("index.html", "index.php", "/_h5ai/public/index.php")

Nginx 1.2

In nginx.conf add:

index  index.html  index.php  /_h5ai/public/index.php;

PDF.js requires Nginx entry for the mjs file extension. Otherwise modules files will be served as application/octet-stream instead of application/javascript.

https://github.com/nginx/nginx/blob/master/conf/mime.types

The MIME type for mjs files can be explicitly included in server configuration:

server
{
    include mime.types;
    types 
    {
        application/javascript mjs;
    }
    ...       
}

Cherokee 1.2

In cherokee.conf add:

vserver!1!directory_index = index.html,index.php,/_h5ai/public/index.php

Redirection with htaccess file

You can also redirect non existent lookups i.e domain/unknown_doc to the /public/ directory.
Change your redirection accordingly!

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^127\.0.0.1$
RewriteCond %{REMOTE_ADDR} !^XXX\.XXX\.XXX\.(.*)$RewriteCond %{REQUEST_URI} !^/_h5ai(.*)$
RewriteCond %{REQUEST_URI} !^/public(.*)$
RewriteRule $ /public/ [L,R=301]
  • copy the _h5ai folder to /var/www/public/
  • try to access domain/public/_h5ai with a web browser
  • you should get a “403 Forbidden” error

Permissions

Give access to the _h5ai directory to Apache

chmod -R 755 /var/www/public/_h5ai/

Give write access to the cache folder of _h5ai
needed for some options (thumbs, zip batch download)

chmod o+w /var/www/public/_h5ai/cache/

Create a symlink to the Public folder.
You can use any other path of your setup.

ln -s /DataVolume/shares/Public/ /var/www/public

Enables the autoindex function of Apache for Directory Listing

a2enmod autoindex

Restart Apache server to enable customization

/etc/init.d/apache2 restart

h5ai Configuration

You can manage all settings from a single file : /_h5ai/private/conf/options.json

Everything is well documented. For example :

  • enable download of multiple files as zip
  • enabling QR codes
  • and much more

You can edit the file options.json also with Notepad. There’s no need to restart the server between changes!