nginx 复制请求 ngx_http_mirror_module mirror


nginx复制请求功能,可以实现一个请求转发到两个接口

用到的模块:ngx_http_mirror_module

 

网上说1.13版本之后自带该模块,我用的1.18确实是自带的,不用重新编译。

没有自带该模块时,编译:

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_mirror_module

make && make install

 

 

使用示例:

示例1:

location / {
    mirror /mirror;
    proxy_pass http://backend;
}

location = /mirror {
    internal;
    proxy_pass http://test_backend$request_uri;
}

 

示例2:

复制body数据

location / {
    mirror /mirror;
    mirror_request_body on;
    proxy_pass http://backend;
}

location = /mirror {
    internal;
    proxy_pass http://log_backend;
}

 

 

 

 


 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM