Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
не работает фильтр
- To: nginx-ru@xxxxxxxxx
- Subject: не работает фильтр
- From: "o1egus" <nginx-forum@xxxxxxxx>
- Date: Mon, 31 May 2010 06:40:23 -0400
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mickey.jlkhosting.com; s=x; h=Sender:From:Message-ID:Content-Transfer-Encoding:Content-Type:Subject:To:Date; bh=/fL6dV/TnjAzsuJAf1njU+iW9PiGwwek+AabcJ5xotU=; b=leZCWdG6v3lPlZ00nwPEGhCoFjjB3Ms89/mRvsSSWroEOnwnnu864OB2nKZTyQ431ZgnLlblWvF7BqI68Xaiz1+ZlIB4r60i4N6CkBg4XUUBFkyv0BYbSuaL7nozPrjO;
Привет.
Хочу написать простейший фильтр, который как то меняет тело ответа. Но почему
то моя callback функция ngx_http_pg_body_filter даже не вызывается. Подскажите
что не так делаю.
В качестве источников пользовался
http://www.evanmiller.org/nginx-modules-guide.html и модулем nginx под
названием ngx_http_chunked_filter_module.c
Вот мой модуль.
[code]
#include "pg.h"
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
static ngx_int_t ngx_http_pg_filter_init(ngx_conf_t *cf);
static ngx_int_t ngx_http_pg_header_filter(ngx_http_request_t *r);
static ngx_int_t ngx_http_pg_body_filter(ngx_http_request_t *r, ngx_chain_t
*in);
static ngx_http_module_t ngx_http_pg_module_ctx = {
NULL, /* preconfiguration */
ngx_http_pg_filter_init, /* postconfiguration */
NULL, /* create main configuration */
NULL, /* init main configuration */
NULL, /* create server configuration */
NULL, /* merge server configuration */
NULL, /* create location
configuration */
NULL /* merge location
configuration */
};
ngx_module_t ngx_http_pg_module = {
NGX_MODULE_V1,
&ngx_http_pg_module_ctx, /* module context */
NULL, /* 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 ngx_http_output_header_filter_pt ngx_http_next_header_filter;
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
static ngx_int_t ngx_http_pg_header_filter(ngx_http_request_t *r)
{
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,"HELLO HEADER FILTER");
return ngx_http_next_header_filter(r);
}
static ngx_int_t ngx_http_pg_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,"HELLO BODY FILTER");
return ngx_http_next_body_filter(r, in);
}
static ngx_int_t ngx_http_pg_filter_init(ngx_conf_t *cf)
{
ngx_http_next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ngx_http_pg_header_filter;
ngx_http_next_body_filter = ngx_http_top_body_filter;
ngx_http_top_body_filter = ngx_http_pg_body_filter;
return NGX_OK;
}
[/code]
Конфиг.
[code]
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
keepalive_requests 100;
server {
listen 8000;
server_name localhost;
location / {
proxy_pass http://localhost:80;
}
}
}
[/code]
Posted at Nginx Forum: http://forum.nginx.org/read.php?21,92624,92624#msg-92624
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://nginx.org/mailman/listinfo/nginx-ru
|