美文网首页
nginx模块ngx_http_mirror_module

nginx模块ngx_http_mirror_module

作者: Able7 | 来源:发表于2019-03-08 16:50 被阅读0次

ngx_http_mirror_module(nginx 1.13.4开始支持),实现了创建原始请求的镜像,可以实现流量复制的效果。
在业务开发的流程里,针对特定业务,需要评估硬件资源能承载的并发数、吞吐量从而评估系统的服务质量。
这个时候可以用ngx_http_mirror_module 模块来实现流量复制,上手简单,易配置。

image.png

下载nginx 1.14版本:

# wget http://nginx.org/download/nginx-1.14.2.tar.gz  //下载nginx
# wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz //下载lua-nginx-module模块

#yum -y install pcre-devel lua
# ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx  \
--conf-path=/usr/local/nginx/conf/nginx.conf   \
--error-log-path=/usr/local/nginx/logs/error.log  \
--http-log-path=/usr/local/nginx/logs/access.log  \
--with-http_perl_module --with-http_gzip_static_module  \
--with-http_stub_status_module  \
--with-poll_module  \
--with-http_ssl_module  \
--with-http_stub_status_module  \
--add-module=/nginx/lua-nginx-module-0.10.13    //nginx解压之后,编译安装
# make && make install 

mirror的配置参考如下:

upstream test_backend {
        server 47.102.126.49:80;
    }
    server {
        listen  81;
        server_name report.abc.com;
        access_log  logs/report.abc.com_81_access.log xluser;
        error_log   logs/report.abc.com_81_error.log;
        location =/cgi-bin/report.fcg {
                mirror /mirror;     //重点配置
                client_body_buffer_size 10m;
                keepalive_timeout 0;
                access_log  /usr/local/nginx/logs/report.abc.com_report_81_info.log ;
                error_log  /usr/local/nginx/logs/report.abc.com_report_81_info.log ;
                chunked_transfer_encoding off;
                #lua_need_request_body on;
                #content_by_lua_file 'conf/lua/ipfilter.lua';  //自己写的ipfilter模块,需要lua支持
                #lua_code_cache on;
                proxy_pass http://localhost:3005;
        }
        location /mirror {
                internal;
                proxy_pass http://test_backend$request_uri;
        }
   }

官方文档:
https://nginx.org/en/docs/http/ngx_http_mirror_module.html
https://github.com/nginx/nginx/blob/master/src/http/modules/ngx_http_mirror_module.c

相关文章

  • Nginx模块ngx_http_mirror_module 拷贝

    最近在做流量拷贝, 使用了Nginx模块ngx_http_mirror_module, 客户端的流量比较大, 而m...

  • nginx模块ngx_http_mirror_module

    ngx_http_mirror_module(nginx 1.13.4开始支持),实现了创建原始请求的镜像,可以实...

  • 6.Nginx模块学习方法

    Nginx模块 Nginx模块分为 Nginx官方模块 和 第三方模块 , 这里我们拿Nginx官方模块来介绍一下...

  • Nginx核心模块以及指令介绍

    Nginx模块概览 Nginx核心模块以及指令介绍 注意:Nginx的核心模块包含主模块和事件模块,即上图的cor...

  • 应用运维面试核心

    面试题 Nginx模块 你以前用过哪些Nginx模块? upstream 是Nginx负载均衡模块 image ...

  • nginx内核原理

    Nginx的模块 Nginx由内核和模块组成。 Nginx的模块从结构上分为核心模块、基础模块和第三方模块: 核心...

  • nginx 源代码分析 (二)

    1. nginx模块 nginx的功能分布在nginx模块中,一个模块为一个功能单元。每个nginx模块都专注于自...

  • nginx 动态添加模块

    需要用到nginx的tcp模块,以前安装的nginx没有这个模块。 ./nginx -V 可以看到所有包含的模块(...

  • 8.nginx模块介绍

    nginx的模块 1.编译进nginx的模块2.提供那些配置3.模块合适被使用4.提供那些变量 查找nginx模块...

  • nginx 2

    1 nginx 常用模块整理 nginx 常用模块整理1 http核心模块 ngx_http_core_modu...

网友评论

      本文标题:nginx模块ngx_http_mirror_module

      本文链接:https://www.haomeiwen.com/subject/fonrpqtx.html