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;
}

 

 

 

 


 

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2021-12-04
  • 2021-12-03
  • 2021-11-27
  • 2022-02-01
  • 2021-05-10
猜你喜欢
  • 2021-09-11
  • 2021-08-10
  • 2021-10-28
  • 2022-01-26
  • 2021-08-24
相关资源
相似解决方案