首页 > 运维 > linux运维 > Nginx替换过滤文本模块实例教程

Nginx替换过滤文本模块实例教程

零下一度
发布: 2017-06-29 11:15:35
原创
1910 人浏览过
<span style="color: #800080">1<span style="color: #000000">.安装此模块需要先安装sregex运行库<span style="color: #000000">apt-<span style="color: #0000ff">get <strong>update</strong>;<br>apt-<span style="color: #0000ff">get install <strong>git make gcc</strong> -<span style="color: #000000">y  <br>#Centos改成yum
git clone https:<span style="color: #008000">//<span style="color: #008000">github.com/agentzh/<strong>sregex</strong><span style="color: #000000">cd sregex
make
make install
cd ..
git clone https:<span style="color: #008000">//<span style="color: #008000">github.com/agentzh/<strong>replace-filter-nginx-module</strong>wget http:<span style="color: #008000">//<span style="color: #008000">nginx.org/download/nginx-1.2.6.tar.gz
tar zxvf nginx-<span style="color: #800080">1.2.<span style="color: #800080">6<span style="color: #000000">.tar.gz
cd nginx-<span style="color: #800080">1.2.<span style="color: #800080">6<span style="color: #000000">./configure <strong>--add-module=../replace-filter-nginx-</strong><span style="color: #000000"><strong>module</strong>  #自行加其他编译参数
make
make install
nginx.conf的用法举例:<span style="color: #000000">location /<span style="color: #000000">t {
    default_type text/<span style="color: #000000">html;
    echo abc;
    replace_filter <span style="color: #800000">'<span style="color: #800000">ab|abc<span style="color: #800000">'<span style="color: #000000"> X;
}
 
location /<span style="color: #000000"> {
    # proxy_pass/fastcgi_pass/<span style="color: #000000">...
 
    # caseless <span style="color: #0000ff">global<span style="color: #000000"> substitution:
    replace_filter <span style="color: #800000">'<span style="color: #800000">\d+<span style="color: #800000">' <span style="color: #800000">'<span style="color: #800000">blah blah<span style="color: #800000">' <span style="color: #800000">'<span style="color: #800000">ig<span style="color: #800000">'<span style="color: #000000">;
    replace_filter_types text/plain text/<span style="color: #000000">css;
}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
登录后复制

以上是Nginx替换过滤文本模块实例教程的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板