nginx 流量拷贝模块 ngx_http_mirror_module 安装试用

摘要:
7.待确认性能,稳定性,以及生产环境使用的坑。
1. 下载源码编译
https://nginx.org/download/nginx-1.13.4.tar.gz
2. 下载依赖模块包
这里直接yum 安装
yum -y install openssl openssl-devel
yum -y install pcre-devel
3. 安装
可以直接默认 ./configure
我是为了添加https 以及状态监测模块,还有四层负载均衡,比较好的地方是这个模块是
直接内置里面的。
./configure --prefix=/usr/local/nginx –with-http_ssl_module    –with-http_stub_status_module  -with-stream
make  && make install
4. 使用
server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
 		   mirror /mirror; # 可配置多个
    	   mirror_request_body off;
           root html;
           mirror /mirror2;
           index index.html index.htm;
        }
       # mirror配置
        location /mirror {
          proxy_pass http://127.0.0.1:8080$request_uri;
          proxy_pass_request_body off;
          proxy_set_header Content-Length "";
          proxy_set_header X-Original-URI $request_uri;
        }
        location /mirror2 {
          proxy_pass http://127.0.0.1:8081$request_uri;
          proxy_pass_request_body off;
          proxy_set_header Content-Length "";
          proxy_set_header X-Original-URI $request_uri;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    server {
        listen       8080;
        server_name  localhost;
        location / {
            root   html2;
            index  index.html index.htm;
        }
    }
    server {
	listen       8081;
        server_name  localhost;
        location / {
            root   html3;
            index  index.html index.htm;
        }
    }
5. 启动测试即可
/sbin/nginx -t  
/sbin/nginx  
6. 价值
流量拷贝、以前的方案可能有tcpcopy openresty capture_multi 等等,
原生内置了,就是好用,希望openresty 也内置进去,配置capture_muilt 还是有
点不是很方便,如果结合起来,那就太强大了。
7. 待确认
性能,稳定性,以及生产环境使用的坑。
8. 参考资料
https://nginx.org/en/docs/http/ngx_http_mirror_module.html

免责声明:文章转载自《nginx 流量拷贝模块 ngx_http_mirror_module 安装试用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Python 修改微信步数数学基础系列(二)----偏导数、方向导数、梯度、微积分下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Nginx实战系列之功能篇----后端节点健康检查

公司前一段对业务线上的nginx做了整理,重点就是对nginx上负载均衡器的后端节点做健康检查。目前,nginx对后端节点健康检查的方式主要有3种,这里列出: 1 2 3 4 5 6 1、ngx_http_proxy_module模块和ngx_http_upstream_module模块(自带) 官网地址:http://nginx.org/...

docker服务编排--docker-compose

根据哔哩哔哩视频【docker入门2】实战~如何组织一个多容器项目docker-compose进行学习 利用网站https://labs.play-with-docker.com/进行测试 第一步,安装nginx镜像 # 拉取nginx镜像 docker pull nginx # 运行nginx容器 docker run -d -p80:80 --name...

开启Nginx的目录文件列表功能

ngx_http_autoindex_module  此模块用于自动生成目录列表,ngx_http_autoindex_module只在 ngx_http_index_module模块未找到索引文件时发出请求. nginx默认是不允许列出整个目录的。 开启目录列表: 打开nginx.conf文件,在location server 或 http段中加入 au...

openstack-往已有集群中添加控制节点,实现控制节点的高可用

新添加的controller节点基础环境准备 1、yum install centos-release-openstack-train.noarch -y #安装T版yum源 2、yum install python-openstackclient openstack-selinux -y #安装openstack客户端命令和selinux 3、y...

linux Nginx 日志脚本

这篇文章主要介绍了nginx日志切割脚本、nginx日志分析脚本等,需要的朋友可以参考下。 参考自:http://www.jbxue.com/article/13927.html任务计划 crontab -l 1 15 * * * /home/dongnan/sh/split.sh >> /home/dongnan/sh/cron.log 2&...

【VS开发】【C/C++开发】memcpy和memmove的区别

memcpy和memmove()都是C语言中的库函数,在头文件string.h中,作用是拷贝一定长度的内存的内容,原型分别如下: void *memcpy(void *dst, const void *src, size_t count); void *memmove(void *dst, const void *src, size_t count);...