[PATCH] Add 'log_index_denied' directive

Ben Brown ben at isitdoneyet.co.uk
Tue Nov 14 09:13:06 UTC 2017


Thanks for taking the time to look at my patch and give such constructive

On 9 November 2017 at 16:10, Maxim Dounin <mdounin at mdounin.ru> wrote:
> Also, such errors can be easily avoided by using a site-wide index
> file, for example:
>     index index.html /403;
>     location = /403 {
>         return 403;
>     }
> As such, I don't think we need to introduce a special directive to
> control "directory index of ... forbidden" messages.

I agree, I wasn't aware of such a trivial way to avoid these errors.

> The order here isn't alphabetical, so I would recommend adding the
> new directive after log_not_found (if at all).


>>          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?



More information about the nginx-devel mailing list