# diff -Nau freenginx-1.30.0/src/http/modules/ngx_http_index_module.c freenginx-1.30.0_patched/src/http/modules/ngx_http_index_module.c >ngx_http_index_module.c.patch --- freenginx-1.30.0/src/http/modules/ngx_http_index_module.c 2026-04-14 05:23:27.000000000 -0300 +++ freenginx-1.30.0_patched/src/http/modules/ngx_http_index_module.c 2026-04-28 20:07:00.825547974 -0300 @@ -20,6 +20,7 @@ typedef struct { ngx_array_t *indices; /* array of ngx_http_index_t */ size_t max_index_len; + ngx_flag_t off; } ngx_http_index_loc_conf_t; @@ -109,6 +110,12 @@ ngx_http_index_loc_conf_t *ilcf; ngx_http_script_len_code_pt lcode; + ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module); + + if (ilcf->off) { + return NGX_DECLINED; + } + if (r->uri.data[r->uri.len - 1] != '/') { return NGX_DECLINED; } @@ -117,7 +124,6 @@ return NGX_DECLINED; } - ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module); clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); allocated = 0; @@ -369,8 +375,10 @@ u_char *file, ngx_err_t err) { if (err == NGX_EACCES) { - ngx_log_error(NGX_LOG_ERR, r->connection->log, err, - "\"%s\" is forbidden", file); + if (clcf->log_forbidden) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, err, + "\"%s\" is forbidden", file); + } return NGX_HTTP_FORBIDDEN; } @@ -396,6 +404,7 @@ conf->indices = NULL; conf->max_index_len = 0; + conf->off = NGX_CONF_UNSET; return conf; } @@ -409,6 +418,12 @@ ngx_http_index_t *index; + ngx_conf_merge_value(conf->off, prev->off, 0); + + if (conf->off) { + return NGX_CONF_OK; + } + if (conf->indices == NULL) { conf->indices = prev->indices; conf->max_index_len = prev->max_index_len; @@ -470,6 +485,22 @@ ngx_http_index_t *index; ngx_http_script_compile_t sc; + value = cf->args->elts; + + if (ngx_strcmp(value[1].data, "off") == 0) { + if (cf->args->nelts == 2) { + + ilcf->off = 1; + + return NGX_CONF_OK; + } else { + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "\"index off\" must be the only parameter"); + return NGX_CONF_ERROR; + } + } + if (ilcf->indices == NULL) { ilcf->indices = ngx_array_create(cf->pool, 2, sizeof(ngx_http_index_t)); if (ilcf->indices == NULL) { @@ -477,8 +508,6 @@ } } - value = cf->args->elts; - for (i = 1; i < cf->args->nelts; i++) { if (value[i].data[0] == '/' && i != cf->args->nelts - 1) {