<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=koi8-r">
<META content="MSHTML 6.00.2900.3157" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Добрый день,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Обнаружил следующие "странности" при обработке 
конфигурации "location" уровня</FONT></DIV>
<DIV><FONT face=Arial size=2>в модуле-фильтре:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>worker_processes&nbsp; 1;</FONT></DIV>
<DIV><FONT face=Arial size=2>daemon off;<BR>master_process off;</FONT></DIV>
<DIV><FONT face=Arial size=2>* * * *</FONT></DIV>
<DIV><FONT face=Arial size=2>http {</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; * * *</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; server {</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * * 
*</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location / 
{</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; use 
on;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; debug 
on;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location /backend 
{</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
proxy_pass ....;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT face=Arial size=2>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>=============================================================</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>typedef struct {<BR>&nbsp;&nbsp;&nbsp; ngx_flag_t 
use;<BR>&nbsp;&nbsp;&nbsp; ngx_flag_t debug;<BR>} 
ngx_http_draft_loc_conf_t;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>static ngx_command_t&nbsp; 
ngx_http_draft_filter_commands[] = {<BR>&nbsp;&nbsp;&nbsp; { 
ngx_string("use"),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NGX_HTTP_LOC_CONF | 
NGX_CONF_FLAG,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ngx_conf_set_flag_slot,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
NGX_HTTP_LOC_CONF_OFFSET,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
offsetof(ngx_http_draft_loc_conf_t, enable),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
NULL },<BR>&nbsp;&nbsp;&nbsp; { 
ngx_string("debug"),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NGX_HTTP_LOC_CONF | 
NGX_CONF_FLAG,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ngx_conf_set_flag_slot,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
NGX_HTTP_LOC_CONF_OFFSET,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
offsetof(ngx_http_draft_loc_conf_t, debug),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
NULL },<BR>&nbsp;&nbsp;&nbsp; ngx_null_command<BR>};<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>static ngx_http_module_t&nbsp; 
ngx_http_draft_module_ctx = {<BR>&nbsp;&nbsp;&nbsp; 
NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// preconfiguration<BR>&nbsp;&nbsp;&nbsp; 
ngx_http_draft_filter_init,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 
postconfiguration</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// create main configuration<BR>&nbsp;&nbsp;&nbsp; 
NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// init main configuration</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// create server configuration<BR>&nbsp;&nbsp;&nbsp; 
NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// merge server configuration</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
ngx_http_draft_create_loc_conf,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// create location configuration<BR>&nbsp;&nbsp;&nbsp; 
ngx_http_draft_merge_loc_conf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// merge location configuration<BR>};<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>static ngx_int_t ngx_http_draft_filter_init ( 
ngx_conf_t* cf )<BR>{<BR>&nbsp;&nbsp;&nbsp; ngx_http_next_header_filter = 
ngx_http_top_header_filter;<BR>&nbsp;&nbsp;&nbsp; 
ngx_http_top_header_filter&nbsp; = ngx_http_draft_header_filter;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; ngx_http_next_body_filter = 
ngx_http_top_body_filter;<BR>&nbsp;&nbsp;&nbsp; ngx_http_top_body_filter&nbsp; = 
ngx_http_draft_body_filter;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; return 
NGX_OK;<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>static void* ngx_http_draft_create_loc_conf ( 
ngx_conf_t* cf )<BR>{<BR>&nbsp;&nbsp;&nbsp; unsigned i;<BR>&nbsp;&nbsp;&nbsp; 
ngx_http_draft_loc_conf_t* conf;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; conf = ngx_pcalloc ( 
cf-&gt;pool, sizeof(ngx_http_draft_loc_conf_t) );<BR>&nbsp;&nbsp;&nbsp; if ( 
conf == NULL ) return NGX_CONF_ERROR;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
printf("ngx_http_draft_create_loc_conf('%s', %p, %d)\n", cf-&gt;name, 
cf-&gt;args,&nbsp; cf-&gt;args-&gt;nelts);<BR>&nbsp;&nbsp;&nbsp; char** arr = 
cf-&gt;args-&gt;elts; //&nbsp;какой формат элементов 
массива?<BR>&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; cf-&gt;args-&gt;nelts; 
i++)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
printf("[%p]\n", arr[i]);<BR>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; conf-&gt;use = 
NGX_CONF_UNSET;<BR>&nbsp;&nbsp;&nbsp; conf-&gt;debug&nbsp; = 
NGX_CONF_UNSET;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; return 
conf;<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>static char* ngx_http_draft_merge_loc_conf ( 
ngx_conf_t* cf, void* parent, void* child )<BR>{<BR>&nbsp;&nbsp;&nbsp; unsigned 
int i;<BR>&nbsp;&nbsp;&nbsp; ngx_http_draft_loc_conf_t* prev = 
parent;<BR>&nbsp;&nbsp;&nbsp; ngx_http_draft_loc_conf_t* conf = 
child;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; ngx_conf_merge_value ( 
conf-&gt;use, prev-&gt;use, 0 );<BR>&nbsp;&nbsp;&nbsp; ngx_conf_merge_value ( 
conf-&gt;debug, prev-&gt;debug, 0 );</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
printf("ngx_http_draft_merge_loc_conf('%s', %p, %d): use: %d, debug: 
%d\n",&nbsp;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; cf-&gt;name, cf-&gt;args,&nbsp; 
cf-&gt;args-&gt;nelts, conf-&gt;use, conf-&gt;debug);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; return 
NGX_CONF_OK;<BR>}</FONT></DIV>
<DIV><FONT face=Arial 
size=2><BR>===========================================================================</FONT></DIV>
<DIV><FONT face=Arial size=2>$ sbin/nginx -t</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>ngx_http_draft_create_loc_conf('(null)', 0x80b3878, 
1)<BR>[0x4]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
- какой формат?<BR>ngx_http_draft_create_loc_conf('(null)', 0x80b3878, 
1)<BR>[0x6]<BR>ngx_http_draft_create_loc_conf('(null)', 0x80b3878, 
2)<BR>[0x8]<BR>[0x80c1b7c]<BR>ngx_http_draft_create_loc_conf('(null)', 
0x80b3878, 2)<BR>[0x8]<BR>[0x80c2130]</FONT></DIV><FONT face=Arial size=2>
<DIV><BR>ngx_http_draft_merge_loc_conf('(null)', 0x80b3878, 0): use: 0, debug: 
0<BR>ngx_http_draft_merge_loc_conf('(null)', 0x80b3878, 0): use: 1, debug: 
1<BR>ngx_http_draft_merge_loc_conf('(null)', 0x80b3878, 0): use: 0, debug: 
0</DIV>
<DIV><BR>2007/10/09 17:41:14 [info] 18647#0: the configuration file 
conf/nginx.conf syntax is ok<BR>2007/10/09 17:41:14 [info] 18647#0: the 
configuration file conf/nginx.conf was tested successfully</DIV>
<DIV>&nbsp;</DIV>
<DIV>===========================================================================</DIV>
<DIV>&nbsp;</DIV>
<DIV>1)&nbsp;Откуда вызовы до "location / {}" ?</DIV>
<DIV>2)&nbsp;Число вызовов "ngx_http_draft_create_loc_conf" и 
"ngx_http_draft_merge_loc_conf" несовпадает?</DIV>
<DIV>3) Последний вызов "ngx_http_draft_merge_loc_conf" (видимо "location 
/backend {}"?)&nbsp;сбрасывает use и debug.</DIV>
<DIV>&nbsp;</DIV>
<DIV>В результате, если получить указатель</DIV>
<DIV>ngx_http_draft_loc_conf_t*&nbsp;conf = ngx_http_get_module_loc_conf ( r, 
ngx_http_draft_filter_module );</DIV>
<DIV>в ngx_http_draft_body_filter( url = "/" ), то получим:</DIV>
<DIV>&nbsp;</DIV>
<DIV>conf-&gt;use = conf-&gt;debug = 0</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></FONT></BODY></HTML>