Немного замысловато звучит :<font size="2">) Какое-то странное поведение хендлера обнаружил.<br><br>Небольшое введение: модуль - каркас с двумя переменными "blabla" и "blabla_disable". Действия модуля распростроняется на все сервера, кроме тех locations, где будет "blabla_disable on"<br>
Поэтому используется конфигурация уровня location и </font><font size="2">server. Такого я правда пока ни в одном модуле не встречал.</font><br><font style="font-family: courier new,monospace;" size="2"><br></font><font style="font-family: courier new,monospace;" size="2">static ngx_http_module_t ngx_http_blabla_module_ctx = {<br>
NULL, /* preconfiguration */<br> ngx_http_blabla_init, /* postconfiguration */<br><br> NULL, /* create main configuration */<br> NULL, /* init main configuration */<br>
<br> ngx_http_blabla_create_srv_conf, /* create server configuration */<br> ngx_http_blabla_merge_srv_conf, /* merge server configuration */<br><br> ngx_http_blabla_create_loc_conf, /* create location configration */<br>
ngx_http_blabla_merge_loc_conf /* merge location configration */<br>};</font><br><br>В ините добавляется ngx_http_blabla_handler. Пока всё стандартно.<br>Самое интересное поведение - в хендлере:<br><font size="2"><br>
</font><font size="2"><span style="font-family: courier new,monospace;">static ngx_int_t</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ngx_http_blabla_handler(ngx_http_request_t *r)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ngx_http_blabla_srv_conf_t *conf;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ngx_http_blabla_loc_conf_t *confl;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> conf = ngx_http_get_module_srv_conf(r, ngx_http_blabla_module);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> confl = ngx_http_get_module_loc_conf(r, ngx_http_blabla_module);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (confl->disable) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return NGX_DECLINED;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> /* Future logic */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return NGX_DECLINED;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br></font><br>Задумано так, что берется конфигурация переменных уровня сервера и уровня локейшена для запроса.<br>
Проверяется что в этом локейшене <font size="2">"blabla_disable on" и ничего не делается. Во всех остальных случаях идет дальше на обработку.<br>Но в реальности "blabla_disable" проверяется того же уровня, где расположена переменная "blabla".<br>
Как пример, запрос идет на /tamtam И модуль должен пропустить этот запрос. (в реальности это редкий случай, поэтому по умолчанию в<span style="font-family: arial,helvetica,sans-serif;">езде "</span></font><font style="font-family: arial,helvetica,sans-serif;" size="2">blabla_disable off"</font><font size="2">)<br>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">server {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> blabla "test";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> //blabla_disable off;<br><br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> location /tamtam {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> blabla_disable on;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br><br></font>Почему <font style="font-family: arial,helvetica,sans-serif;" size="2">"ngx_http_get_module_loc_conf" </font>берет данные не для запрашиваемого локейшена, а от того места, где идет инициализация хендлера и переменной "blabla"?<br>