Nginx 1.13.4版本新增了ngx_http_mirror_module模块。
ngx_http_mirror_module模块适用于这样一种场景,可以把真实请求引流到测试环境。
配置示例
location / {
mirror /mirror;
proxy_pass http://backend;
}
location /mirror {
internal;
proxy_pass http://test_backend$request_uri;
}
配置两组后台服务器,http://backend指向生产服务器, http://test_backend指向测试服务器。
用户访问生产服务器的同时,请求会被nginx复制发送给测试服务器,需要注意的一点是mirror不会输出http返回内容。