"index off;" directive?

Maxim Dounin mdounin at mdounin.ru
Sat May 9 23:15:34 UTC 2026


Hello!

On Tue, May 05, 2026 at 10:05:36PM -0300, Fabiano Furtado wrote:

[...]

> > # HG changeset patch
> > # User Maxim Dounin <mdounin at mdounin.ru>
> > # Date 1777971559 -10800
> > #      Tue May 05 11:59:19 2026 +0300
> > # Node ID e8bd179e5e7be4e6422918dbc6cace143de7b8ce
> > # Parent  f347a195b373c1d118fd8a929886692f052e8d4b
> > Index: added "index off;".
> >
> > This might be useful to save a syscall if index files should not be used,
> > for example, when autoindex is expected to be used instead.
> >
> > Prodded by Fabiano Furtado.
> 
> Thank you very much for the mention!
> 
> > diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c
> > --- a/src/http/modules/ngx_http_index_module.c
> > +++ b/src/http/modules/ngx_http_index_module.c
> > ...
> >              return NGX_CONF_ERROR;
> >          }
> 
> I'll test your patch, though I'm confident it's already working perfectly.

Looking more into this, I think about only checking "off" if there 
is only one argument.  Resulting syntax would be:

    index off | file ...;

With this approach,

    index off;

will switch off index usage, and will reject any attempts to define 
additional indexes, so

    index off;
    index index.html;

and

    index index.html;
    index off;

will be rejected.  At the same time, when "index off;" is clearly 
not the intention due to multiple arguments of the directive, such 
as in

    index index.html off on;

or 

    index off index.html;

all arguments would be considered index file names, exactly as it 
works now.

I tend to think this would be clearer from the syntax point of 
view.

(The patch is essentially the same, but without checking for "off" 
in the loop.)

What do you think?

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list