微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NGINX头部和身体filter模块

我一直在编写一个Nginxfilter模块,可以读/写入站请求的cookie。 如果一个特定的cookie设置不正确(即authenticationcookie),它将设置出局标题状态为相应的错误代码。 按照Evan Miller的教程的方向,这很好。 下一部分,我正在尝试工作(并没有到目前为止)是身体filter被调用,所以我可以在遇到错误响应时插入/replace正文响应文本。 我再次按照埃文·米勒的身体filter的教程 ,我不能为我的生活得到这个工作。 这是我的设置:

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_http_module_t ngx_http_source_cookie_module_ctx = { NULL,/* preconfiguration */ ngx_http_source_cookie_init,/* postconfiguration */ NULL,/* create main configuration */ NULL,/* init main configuration */ NULL,/* create server configuration */ NULL,/* merge server configuration */ ngx_http_source_cookie_create_loc_conf,/* create location configuration */ ngx_http_source_cookie_merge_loc_conf /* merge location configuration */ }; ngx_module_t ngx_http_source_cookie_module = { NGX_MODULE_V1,&ngx_http_source_cookie_module_ctx,/* module context */ ngx_http_source_cookie_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 ngx_int_t ngx_http_source_cookie_header_filter(ngx_HTTP_Request_t *r) { // this gets invoked ... } /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ static ngx_int_t ngx_http_body_filter(ngx_HTTP_Request_t *r,ngx_chain_t *in) { // this never get invoked ... } /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ static ngx_int_t ngx_http_source_cookie_init(ngx_conf_t *cf) { // registering of my filters ngx_http_next_header_filter = ngx_http_top_header_filter; ngx_http_top_header_filter = ngx_http_source_cookie_header_filter; ngx_http_next_body_filter = ngx_http_top_body_filter; ngx_http_top_body_filter = ngx_http_body_filter; return NGX_OK; }

这是我的基本设置,据我所知,这是所有我遇到的示例/教程的点。 我想知道是否有什么不同,我需要启用…像一个Nginxconfiguration选项,Nginx ./configure编译选项等。

任何帮助是极大的赞赏。

在烙铁上安装tkinter

Nginx中有没有解压模块?

为什么我的“hello world”Python C模块在除IDLE以外的任何地方都能正常工作?

未知指令“perl_modules”

在内核模块中创build一个以太网数据包并发送

试图为Python安装正则expression式

我怎样才能检查Apache模块版本?

如何在Ubuntu的启动时加载自定义模块?

试图升级点,但错误“WinError 5”出现

在Lazarus中的Windows模拟Apache模块

我注意到,Evan不能修复ngx_http_<module_name>_header_filter() http内容长度。

如果我不添加http内容长度( r->headers_out.content_length_n ),则插入的文本到请求的结尾将不会从Nginx-1.2.7稳定输出

你也可以看到页脚过滤器模块 。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐