The location configuration bug?

Denis Erygin erygin at corp.mail.ru
Thu Oct 11 03:48:02 MSD 2007


Тема закрыта.

Причина была в том, что "/index.html" воспринимался как каталог.

----- Original Message ----- 
From: "AlexeyK" <itsmegawtf at gmail.com>
To: <nginx-ru at sysoev.ru>
Sent: Tuesday, October 09, 2007 7:00 PM
Subject: Re: The location configuration bug?


> http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#location
> Первый абзац я имел в виду.
>
> Чтобы debug и use включались, мне думается нужно указать конкретный локейшн.
>
> location = /index.html {
>    use on;
>    debug on;
> }
>
> сработает?
>
>
> 2007/10/9, Denis Erygin <erygin at corp.mail.ru>:
>> Хотелось бы просто разобраться,
>> почему на запрос типа "GET /index.html"
>> получаем use = debug = 0 при данном конфиге.
>>
>> >в мануале четко сказано как идет
>> > обработка,
>> Где конкретно?
>>
>> ----- Original Message -----
>> From: "AlexeyK" <itsmegawtf at gmail.com>
>> To: <nginx-ru at sysoev.ru>
>> Sent: Tuesday, October 09, 2007 6:09 PM
>> Subject: Re: The location configuration bug?
>>
>>
>> > Рискну предположить, что вы считаете, первым всегда обрабатывается
>> > location / { }, но это не так, в мануале четко сказано как идет
>> > обработка, к тому же если ваш третий пункт верен, то дебаг будет
>> > срабатывать исключительно для GET / или подобных запросов, но не
>> > включать в себя GET /backend, т.к. для него существует его собственное
>> > правило в location /backend { }
>> >
>> >
>> > 2007/10/9, Denis Erygin <erygin at corp.mail.ru>:
>> >>
>> >>
>> >> Добрый день,
>> >>
>> >> Обнаружил следующие "странности" при обработке конфигурации "location"
>> >> уровня
>> >> в модуле-фильтре:
>> >>
>> >> worker_processes  1;
>> >> daemon off;
>> >> master_process off;
>> >> * * * *
>> >> http {
>> >>    * * *
>> >>    server {
>> >>        * * *
>> >>       location / {
>> >>         use on;
>> >>         debug on;
>> >>       }
>> >>
>> >>       location /backend {
>> >>          proxy_pass ....;
>> >>       }
>> >>    }
>> >> }
>> >>
>> >> =============================================================
>> >>
>> >> typedef struct {
>> >>     ngx_flag_t use;
>> >>     ngx_flag_t debug;
>> >> } ngx_http_draft_loc_conf_t;
>> >>
>> >> static ngx_command_t  ngx_http_draft_filter_commands[] = {
>> >>     { ngx_string("use"),
>> >>       NGX_HTTP_LOC_CONF | NGX_CONF_FLAG,
>> >>       ngx_conf_set_flag_slot,
>> >>       NGX_HTTP_LOC_CONF_OFFSET,
>> >>       offsetof(ngx_http_draft_loc_conf_t, enable),
>> >>       NULL },
>> >>     { ngx_string("debug"),
>> >>       NGX_HTTP_LOC_CONF | NGX_CONF_FLAG,
>> >>       ngx_conf_set_flag_slot,
>> >>       NGX_HTTP_LOC_CONF_OFFSET,
>> >>       offsetof(ngx_http_draft_loc_conf_t, debug),
>> >>       NULL },
>> >>     ngx_null_command
>> >> };
>> >>
>> >> static ngx_http_module_t  ngx_http_draft_module_ctx = {
>> >>     NULL,                                  //
>> >> preconfiguration
>> >>     ngx_http_draft_filter_init,        // postconfiguration
>> >>
>> >>     NULL,                                  // create main
>> >> configuration
>> >>     NULL,                                  // init main
>> >> configuration
>> >>
>> >>     NULL,                                  // create server
>> >> configuration
>> >>     NULL,                                  // merge server
>> >> configuration
>> >>
>> >>     ngx_http_draft_create_loc_conf,         // create
>> >> location configuration
>> >>     ngx_http_draft_merge_loc_conf           // merge
>> >> location configuration
>> >> };
>> >>
>> >> static ngx_int_t ngx_http_draft_filter_init ( ngx_conf_t* cf )
>> >> {
>> >>     ngx_http_next_header_filter = ngx_http_top_header_filter;
>> >>     ngx_http_top_header_filter  = ngx_http_draft_header_filter;
>> >>
>> >>     ngx_http_next_body_filter = ngx_http_top_body_filter;
>> >>     ngx_http_top_body_filter  = ngx_http_draft_body_filter;
>> >>
>> >>     return NGX_OK;
>> >> }
>> >>
>> >> static void* ngx_http_draft_create_loc_conf ( ngx_conf_t* cf )
>> >> {
>> >>     unsigned i;
>> >>     ngx_http_draft_loc_conf_t* conf;
>> >>
>> >>     conf = ngx_pcalloc ( cf->pool,
>> >> sizeof(ngx_http_draft_loc_conf_t) );
>> >>     if ( conf == NULL ) return NGX_CONF_ERROR;
>> >>
>> >>     printf("ngx_http_draft_create_loc_conf('%s', %p,
>> >> %d)\n", cf->name, cf->args,  cf->args->nelts);
>> >>     char** arr = cf->args->elts; // какой формат элементов массива?
>> >>     for (i = 0; i < cf->args->nelts; i++)
>> >>     {
>> >>        printf("[%p]\n", arr[i]);
>> >>     }
>> >>
>> >>     conf->use = NGX_CONF_UNSET;
>> >>     conf->debug  = NGX_CONF_UNSET;
>> >>
>> >>     return conf;
>> >> }
>> >>
>> >> static char* ngx_http_draft_merge_loc_conf ( ngx_conf_t* cf, void*
>> >> parent,
>> >> void* child )
>> >> {
>> >>     unsigned int i;
>> >>     ngx_http_draft_loc_conf_t* prev = parent;
>> >>     ngx_http_draft_loc_conf_t* conf = child;
>> >>
>> >>     ngx_conf_merge_value ( conf->use, prev->use, 0 );
>> >>     ngx_conf_merge_value ( conf->debug, prev->debug, 0 );
>> >>
>> >>     printf("ngx_http_draft_merge_loc_conf('%s', %p, %d):
>> >> use: %d, debug: %d\n",
>> >>     cf->name, cf->args,  cf->args->nelts, conf->use, conf->debug);
>> >>
>> >>     return NGX_CONF_OK;
>> >> }
>> >>
>> >> ===========================================================================
>> >> $ sbin/nginx -t
>> >>
>> >> ngx_http_draft_create_loc_conf('(null)', 0x80b3878, 1)
>> >> [0x4]
>> >>                       - какой формат?
>> >> ngx_http_draft_create_loc_conf('(null)', 0x80b3878, 1)
>> >> [0x6]
>> >> ngx_http_draft_create_loc_conf('(null)', 0x80b3878, 2)
>> >> [0x8]
>> >> [0x80c1b7c]
>> >> ngx_http_draft_create_loc_conf('(null)', 0x80b3878, 2)
>> >> [0x8]
>> >> [0x80c2130]
>> >>
>> >> ngx_http_draft_merge_loc_conf('(null)', 0x80b3878, 0): use:
>> >> 0, debug: 0
>> >> ngx_http_draft_merge_loc_conf('(null)', 0x80b3878, 0): use:
>> >> 1, debug: 1
>> >> ngx_http_draft_merge_loc_conf('(null)', 0x80b3878, 0): use:
>> >> 0, debug: 0
>> >>
>> >> 2007/10/09 17:41:14 [info] 18647#0: the configuration file
>> >> conf/nginx.conf
>> >> syntax is ok
>> >> 2007/10/09 17:41:14 [info] 18647#0: the configuration file
>> >> conf/nginx.conf
>> >> was tested successfully
>> >>
>> >> ===========================================================================
>> >>
>> >> 1) Откуда вызовы до "location / {}" ?
>> >> 2) Число вызовов "ngx_http_draft_create_loc_conf" и
>> >> "ngx_http_draft_merge_loc_conf" несовпадает?
>> >> 3) Последний вызов "ngx_http_draft_merge_loc_conf" (видимо "location
>> >> /backend {}"?) сбрасывает use и debug.
>> >>
>> >> В результате, если получить указатель
>> >> ngx_http_draft_loc_conf_t* conf = ngx_http_get_module_loc_conf ( r,
>> >> ngx_http_draft_filter_module );
>> >> в ngx_http_draft_body_filter( url = "/" ), то получим:
>> >>
>> >> conf->use = conf->debug = 0
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>>
>>
>>
> 






More information about the nginx-ru mailing list