【nginx location规则】nginx中多规则替换过滤模块nginx_substitutions_filter用法

更新时间:2019-05-19    来源:Google    手机版     字体:

【www.bbyears.com--Google】

安装方法:
 

 代码如下 cd /tmp
yum install subversion
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only

在编译nginx时加上:
 

 代码如下 ./configure --add-module=/tmp/substitutions4nginx-read-only

使用方法
有两条指令:subs_filter_types,subs_filter
subs_filter_types
语法: subs_filter_types mime-type [mime-types]
默认:subs_filter_types text/html
适用区域:http, server, location
subs_filter_types是用来指令需要替换的文件类型,默认是text/html类型。此模块无法处理经过压缩的内容,虽然能与gzip filter模块兼容,但无法处理反向代理返回的内容。
当需要处理反向代理的内容时,可以使用如下语句禁用压缩:
proxy_set_header Accept-Encoding "";
subs_filter
语法;subs_filter 源字段串 目标字段串 [gior]
默认:无
适用区域:http, server, location

    subs_filter指令允许在nginx响应输出内容时替换源字段串(正则或固定)为目标字符串。第三个标志含意如下:
    g(默认): 替换所有匹配的字段串。
    i: 执行区分大小写的匹配。
    o: 仅替换首个匹配字符串。
    r: 使用正则替换模式,默认是固定模式。

本文来源:http://www.bbyears.com/seo/51775.html