[PATCH] autoindex_ignore Re: [PATCH] Re: nginx-0.7.55

Sergey A. Osokin osa at macomnet.ru
Thu May 7 09:42:18 MSD 2009


On Wed, May 06, 2009 at 05:30:50PM +0300, maxhl at hitline.net.ua wrote:
> Спасибо патч работает. Было бы хорошо реализовать опцию как в апаче. 
> 
> -----Original Message-----
> From: owner-nginx-ru at sysoev.ru [mailto:owner-nginx-ru at sysoev.ru] On Behalf
> Of Sergey A. Osokin
> Sent: Wednesday, May 06, 2009 4:57 PM
> To: nginx-ru at sysoev.ru
> Cc: maxhl at hitline.net.ua
> Subject: [PATCH] Re: nginx-0.7.55
> 
> On Wed, May 06, 2009 at 03:13:59PM +0300, maxhl at hitline.net.ua wrote:
> > Подскажите а можно заставить ngx_http_autoindex_module показывать 
> > директории начинающиеся с точки ? Типа .com .net?
 
Патч во втором приближении.

----------------------------------------------
Дополнительная директива.

syntax: autoindex_ignore [on|off]
default: autoindex_ignore off
context: http, server, location

Директива разрешает или запрещает вывод листинга файлов с точкой.
----------------------------------------------

--- src/http/modules/ngx_http_autoindex_module.c.orig	2009-05-06 17:40:29.000000000 +0400
+++ src/http/modules/ngx_http_autoindex_module.c	2009-05-07 09:29:54.000000000 +0400
@@ -36,6 +36,7 @@
     ngx_flag_t     enable;
     ngx_flag_t     localtime;
     ngx_flag_t     exact_size;
+    ngx_flag_t     ignore;
 } ngx_http_autoindex_loc_conf_t;
 
 
@@ -77,6 +78,13 @@
       offsetof(ngx_http_autoindex_loc_conf_t, exact_size),
       NULL },
 
+    { ngx_string("autoindex_ignore"),
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+      ngx_conf_set_flag_slot,
+      NGX_HTTP_LOC_CONF_OFFSET,
+      offsetof(ngx_http_autoindex_loc_conf_t, ignore),
+      NULL },
+
       ngx_null_command
 };
 
@@ -269,9 +277,22 @@
 
         len = ngx_de_namelen(&dir);
 
-        if (ngx_de_name(&dir)[0] == '.') {
-            continue;
-        }
+        if (alcf->ignore) {
+            if (len == 1 && ngx_de_name(&dir)[0] == '.') {
+                continue;
+       	    }
+
+	    if (len == 2
+	        && ngx_de_name(&dir)[0] == '.'
+	        && ngx_de_name(&dir)[1] == '.')
+	    {
+	        continue;
+	    }
+	} else {
+            if (ngx_de_name(&dir)[0] == '.') {
+                continue;
+            }
+	}
 
         if (!dir.valid_info) {
 
@@ -618,6 +639,7 @@
     conf->enable = NGX_CONF_UNSET;
     conf->localtime = NGX_CONF_UNSET;
     conf->exact_size = NGX_CONF_UNSET;
+    conf->ignore = NGX_CONF_UNSET;
 
     return conf;
 }
@@ -632,6 +654,7 @@
     ngx_conf_merge_value(conf->enable, prev->enable, 0);
     ngx_conf_merge_value(conf->localtime, prev->localtime, 0);
     ngx_conf_merge_value(conf->exact_size, prev->exact_size, 1);
+    ngx_conf_merge_value(conf->ignore, prev->ignore, 0);
 
     return NGX_CONF_OK;
 }

-- 
Sergey A. Osokin
osa at MAcomnet.ru





More information about the nginx-ru mailing list