sub_filter

 

 


sub_filter

 

function: modifies a response by replacing one specified string by another.

module: ngx_http_sub_module # not built by default => --with-http_sub_module

location / {
    ...
    proxy_set_header Accept-Encoding '';
    
    # Default: sub_filter_types text/html;
    sub_filter_types *;
    
    # Default: sub_filter_once on;
    sub_filter_once off;
    
    # Allows preserving the “Last-Modified” header field from the original response
    # during replacement to facilitate response caching.
    sub_filter_last_modified on
    
    # sub_filter 'orig_string' 'replacement';
    sub_filter '<a href="http://127.0.0.1:8080/'  '<a href="https://$host/';
    ...
}