nginx ngx_http_mirror_module 安装试用

1. 下载源码编译

https://nginx.org/download/nginx-1.13.4.tar.gz

2. 下载依赖模块包

这里直接yum 安装

yum   install    openssl   openssl-devel

yum    install   pcre-devel

3. 安装

可以直接默认  ./configure

我是为了添加https 以及状态监测模块,还有四层负载均衡,比较好的地方是这个模块是

直接内置里面的。

./configure--prefix=/usr/local/nginx–with-http_ssl_module–with-http_stub_status_module-with-stream

make&&makeinstall

4.  使用

server{

listen80;

server_namelocalhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location/{

mirror/mirror;# 可配置多个

mirror_request_bodyoff;

roothtml;

mirror/mirror2;

indexindex.htmlindex.htm;

}

# mirror配置

location/mirror{

proxy_passhttp://127.0.0.1:8080$request_uri;

proxy_pass_request_bodyoff;

proxy_set_headerContent-Length"";

proxy_set_headerX-Original-URI$request_uri;

}

location/mirror2{

proxy_passhttp://127.0.0.1:8081$request_uri;

proxy_pass_request_bodyoff;

proxy_set_headerContent-Length"";

proxy_set_headerX-Original-URI$request_uri;

}

error_page500502503504/50x.html;

location=/50x.html {

roothtml;

}

}

server{

listen8080;

server_namelocalhost;

location/{

roothtml2;

indexindex.htmlindex.htm;

}

}

server{

listen8081;

server_namelocalhost;

location/{

roothtml3;

indexindex.htmlindex.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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容