From 5e621202bdf40d415b5710687713167acfa32805 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Thu, 18 Aug 2016 19:21:07 +0300 Subject: [PATCH] Use only the new-style module configuration for dynamic builds For static builds we still need to manually reorder $HTTP_MODULES, and we cannot source "auto/module" like the new-style configuration mode needs, because the "auto/module" snippet modifies $HTTP_MODULES itself, but ignores the new $ngx_module_order variable when doing a static build. Fortunately, the old-style way of configuring the module is still working in all Nginx versions for statically built modules, so we can keep using that for static builds. This fixes issue #46. --- config | 4 ++-- t/has-index.test | 7 +++++++ t/has-index/index.html | 10 ++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 t/has-index.test create mode 100644 t/has-index/index.html diff --git a/config b/config index af3a814..4ef3809 100644 --- a/config +++ b/config @@ -1,12 +1,12 @@ # vim:ft=sh: ngx_addon_name=ngx_http_fancyindex_module -if test -n "$ngx_module_link"; then +if [ "$ngx_module_link" = DYNAMIC ] ; then ngx_module_type=HTTP ngx_module_name=ngx_http_fancyindex_module ngx_module_srcs="$ngx_addon_dir/ngx_http_fancyindex_module.c" ngx_module_deps="$ngx_addon_dir/template.h" - + ngx_module_order="$ngx_module_name ngx_http_autoindex_module" . auto/module else # XXX: Insert fancyindex module *after* index module! diff --git a/t/has-index.test b/t/has-index.test new file mode 100644 index 0000000..cf34207 --- /dev/null +++ b/t/has-index.test @@ -0,0 +1,7 @@ +#! /bin/bash +cat <<--- +This test ensures that the "index.html" is returned instead of a directory +listing when fetching a directory which contains an index file. +-- +nginx_start +diff -u "${TESTDIR}/has-index/index.html" <( fetch /has-index/ ) 1>&2 diff --git a/t/has-index/index.html b/t/has-index/index.html new file mode 100644 index 0000000..419ae86 --- /dev/null +++ b/t/has-index/index.html @@ -0,0 +1,10 @@ + + + + + Index file test + + + This is index.html. + +