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