проблема с "hello world" модулем

Ivan bdfy на mail.ru
Пт Авг 6 19:06:33 MSD 2010


Есть модуль под nginx который в общем-то ничего не делает.:):

#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>

# include <string.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
# include <limits.h>

typedef struct {
   ngx_uint_t testtest;
} ngx_http_hello_world_conf_t;



static void* ngx_http_hello_world_create_conf(ngx_conf_t *cf);

static ngx_command_t  ngx_http_hello_world_commands[] = {

    { ngx_string("testtest"),
      NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
      ngx_conf_set_num_slot,
      NGX_HTTP_LOC_CONF_OFFSET,
      offsetof(ngx_http_hello_world_conf_t, testtest),
      NULL },
    ngx_null_command
};

static ngx_http_module_t  ngx_http_hello_world_module_ctx = {
  NULL,                          /* preconfiguration */
  NULL,                          /* postconfiguration */

  NULL,                          /* create main configuration */
  NULL,                          /* init main configuration */

  NULL,                          /* create server configuration */
  NULL,                          /* merge server configuration */
  ngx_http_hello_world_create_conf,
  NULL
};

ngx_module_t ngx_http_hello_world_module = {
  NGX_MODULE_V1,
  &ngx_http_hello_world_module_ctx, /* module context */
  ngx_http_hello_world_commands,   /* module directives */
  NGX_HTTP_MODULE,               /* module type */
  NULL,                          /* init master */
  NULL,                          /* init module */
  NULL,                          /* init process */
  NULL,                          /* init thread */
  NULL,                          /* exit thread */
  NULL,                          /* exit process */
  NULL,                          /* exit master */
  NGX_MODULE_V1_PADDING
};

static void* ngx_http_hello_world_create_conf(ngx_conf_t *cf)
{
    ngx_http_hello_world_conf_t  *conf;

//    conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_hello_world_conf_t));
//    if (conf == NULL) {
//        return NULL;
//    }
//    return conf;
}




И есть конфиг файл:
http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location /test  {
                testtest 11;
                return 404;
    }

}


По идее для переменной testtest в данном случае должно присваиваться значение 11.

Но при запуске nginx возникает ошибка:
emerg]: "testtest" directive is duplicate in /usr/local/nginx//conf/nginx.conf:29

В чем может быть проблема ?





Подробная информация о списке рассылки nginx-ru