Nginx 过滤sub模块

Posted Jee

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx 过滤sub模块相关的知识,希望对你有一定的参考价值。

通过 --with-http_sub_module 编译进nginx

sub_filter 指令

Syntax: sub_filter string replacement;
Default:
Context:

httpserverlocation

 

 

 

 

设置要替换的字符串和替换字符串。要替换的字符串匹配,忽略大小写。要替换的字符串(1.9.4)和替换字符串可以包含变量。可以在一个配置级别(1.9.4)上指定几个SUB U过滤器指令。如果并且仅当当前级别上没有定义子筛选器指令时,这些指令才从上一级别继承。

sub_filter_last_modified 指令

Syntax: sub_filter_last_modified on | off;
Default:
sub_filter_last_modified off;
Context: httpserverlocation

 

 

 

 

是否显示原先修改的值

sub_filter_once  指令

Syntax: sub_filter_once on | off;
Default:
sub_filter_once on;
Context: httpserverlocation

 

 

 

 

只修改一次 还是修改整个匹配 默认 打开 只修改第一个匹配到的文本

sub_filter_types 指令

Syntax: sub_filter_types mime-type ...;
Default:
sub_filter_types text/html;
Context: httpserverlocation

 

 

 

 

只针对什么响应替换 

location / {
                sub_filter nginx.org www.baidu.com;
        }

 

以上是关于Nginx 过滤sub模块的主要内容,如果未能解决你的问题,请参考以下文章

nginx的with-http_sub_module模块使用之替换字符串

Nginx—— sub_module模块详解

编译nginx的源码安装subs_filter模块

编译nginx的源码安装subs_filter模块

Nginx学习—http过滤模块

nginx ldap模块使用