[PATCH] Add 'log_index_denied' directive

Maxim Dounin mdounin at mdounin.ru
Tue Nov 14 12:53:15 UTC 2017


Hello!

On Tue, Nov 14, 2017 at 09:13:06AM +0000, Ben Brown wrote:

[...]

> >>          if (ngx_http_map_uri_to_path(r, &path, &root, 0) != NULL) {
> >> -            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
> >> -                          "directory index of \"%s\" is forbidden", path.data);
> >> +            clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
> >> +            if (clcf->log_index_denied) {
> >
> > Are there any reasons to call ngx_http_map_uri_to_path() if we are
> > not going to use the result?
> >
> 
> I honestly don't know - that code is already there. I'm very inexperienced with
> this code base so just looked for where this message is generated and wrapped
> it in an 'if'. Should this call not be here in the current codebase?

As far as I see, the call is only needed to generate path as used 
in the error message.  If we are not going to use the result 
(assuming clcf->log_index_denied is 0 with your patch), probably 
there are no reasons to call it at all, and clcf->log_index_denied 
check should be done before the call.

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


More information about the nginx-devel mailing list