复制(或称镜像)request
@see http://nginx.org/en/docs/http/ngx_http_mirror_module.html
location / {
mirror /mirror;
mirror_request_body off;
proxy_pass http://backend;
}
location = /mirror {
internal;
proxy_pass http://log_backend;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
internal 指定此location只能被“内部的”请求调用,外部的调用请求会返回”Not found” (404)
proxy_pass 指定将镜像数据发送给test server的地址
proxy_set_header 设置镜像流量的头部
原始uri不会镜像,可以通过$request_uri变量取得原始请求的uri