subs_filter_bypass

The `subs_filter_bypass` directive disables string substitutions based on the values of specified variables.

Syntaxsubs_filter_bypass $variable1 [ $variable2 ... ];
Defaultnone
Contexthttp, server, location
Arguments1+

Description

The subs_filter_bypass directive in the NGINX 'String Substitutions Module' allows users to conditionally disable string substitution filters within a given context (http, server, or location) based on the state of specific variables. This means that if the provided variables are not empty and do not equal '0', the substitution functionality will be bypassed, preventing any configured substitutions from occurring.

This directive is particularly useful in scenarios where substitutions are not needed based on certain conditions or configurations. For example, if certain request parameters indicate that a response should not be altered, the subs_filter_bypass directive can be set to point to those parameters, ensuring the original response is sent back without any substitutions, which can be important for performance or integrity of the data being served.

The syntax requires one or more variable names to be specified as arguments. When evaluated, if any of these variables return a truthy value (non-empty and not equal to '0'), the substitutions will be effectively skipped. This flexibility allows for greater control over the response manipulation by tailoring string replacements only to desired cases.

Config Example

location / {
    subs_filter_types text/html;
    subs_filter_bypass $arg_no_subs;
    subs_filter a.example.com b.example.com;
}

Ensure the specified variables are properly defined in your context, as uninitialized variables may lead to unexpected behavior.

Be cautious about using too many variables in the bypass condition as it may complicate the logic and readability of the configuration.

← Back to all directives