What is the use sub_filter directives in Nginx?


Posted On: Feb 22, 2018


A sub_filter directive in Nginx is a replacement string. It allows you to perform modifications by replacing specific string to another one. The updated version of Nginx allows you to use multiple sub_filter directives simultaneously. There are different sub_filter directives for different purposes like

  • To set a string replacement

    Syntax: sub_filter string replacement
  • To preserve the last-modified header

    Syntax: sub_filter_last_modified on | off;

    Default: sub_filter_last_modified off;
  • To remove the header field with specific content

    Syntax: sub_filter_once on | off

    Default: sub_filter_once on;

  • Indicate the place of each string either for replacing once or repeatedly

    Syntax: sub_filter_types mime-type .

    Default: sub_filter_types text/html;

It is always suggested not to use a third party sub filter module, it may be powerful but there can be a lot of bugs. Instead you csj use the standard sub filter for your needs.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Nginx Interview Questions

    What is Nginx?

    Nginx is a type of an open source web server which is especially used for reverse proxy, load balancer,..

    Nginx Interview Questions

    In what language was the Nginx software being written?

    The language in which the Nginx software is written is ‘C’ Language...

    Nginx Interview Questions

    What are the main tasks of the Nginx web server?

    The following are the main tasks of the Nginx web server:..