From 2e7dc9557c65e30e67f83ebd31dcf3ab90a75f3a Mon Sep 17 00:00:00 2001 From: Alex Thomassen Date: Wed, 9 Oct 2024 16:43:00 +0000 Subject: [PATCH] Update README --- README.md | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9efd2b..5b42c9c 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,39 @@ AutoIndex Plus is an alternative to the default autoindex module of NGINX. It's 4. Add the following to your NGINX configuration file: ```nginx -# Note that `/media` should be replaced with the directory you want to enable AutoIndex Plus on. -# The preceding `~` is a regex match, so it will match `/media`, `/media/`, `/media/anything`, etc. -# The trailing `(.*)/$` is a regex capture group, which will capture all directories inside `/media`. This is necessary to make the autoindex work properly on subdirectories. -location ~ /media(.*)/$ { +# Note that `/my/media` should be replaced with the directory you want to enable AutoIndex Plus on. +# The preceding `~` is a regex match, so it will match `/my/media`, `/my/media/`, `/my/media/anything`, etc. +# The trailing `(.*)/$` is a regex capture group, which will capture all directories inside `/my/media`. This is necessary to make the autoindex work properly on sub-directories. +location ~ /my/media(.*)/$ { + autoindex on; + autoindex_format json; + addition_types application/json; + + add_before_body /_autoindex/_header.html; + add_after_body /_autoindex/_footer.html; + + add_header Content-Type "text/html; charset=utf-8"; +} +``` + +```nginx +# If you want to enable AutoIndex Plus on the root directory, you can use the following examples instead. +# This block ensures it works on the just the actual root directory. +location ~ /$ { + autoindex on; + autoindex_format json; + addition_types application/json; + + add_before_body /_autoindex/_header.html; + add_after_body /_autoindex/_footer.html; + + add_header Content-Type "text/html; charset=utf-8"; +} + +# This block ensures it works on all sub-directories as well, but only directories. +# From my testing, `location /` would cause some oddities with mime types on certain files (mostly text files). +# Suggestions on how to improve this are welcome. +location ~ /(.*)/$ { autoindex on; autoindex_format json; addition_types application/json;