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


本文摘自PHP中文网,作者零下一度,侵删。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<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替换过滤文本模块实例教程的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

怎么在linux系统中以单容器安装nginx+asp.net core

关于nginx location指令详解

nginx上出现403应该怎么解决

如何完全卸载nginx

详解nginx高并发配置参数

nginx配置文件实例详解

详细介绍nginx的rewrite(地址重定向)

linux内核的五大模块分别是什么

怎么更改nginx配置文件路径

nginx怎么配置文件路径

更多相关阅读请进入《nginx》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...