ngx_http_mirror_module 模組

範例設定
指令
     mirror
     mirror_request_body

ngx_http_mirror_module 模組 (1.13.4) 透過建立背景鏡像子請求來實作原始請求的鏡像。鏡像子請求的回應會被忽略。

範例設定

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

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

指令

語法 mirror uri | off;
預設
mirror off;
Context (上下文) http, server, location

設定原始請求將被鏡像到的 URI。在相同的設定層級上可以指定多個鏡像。

語法 mirror_request_body on | off;
預設
mirror_request_body on;
Context (上下文) http, server, location

指示是否鏡像客戶端請求主體。當啟用時,將在建立鏡像子請求之前讀取客戶端請求主體。在這種情況下,由 proxy_request_bufferingfastcgi_request_bufferingscgi_request_bufferinguwsgi_request_buffering 指令設定的非緩衝客戶端請求主體代理將被禁用。

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