首页 » PHP教程 » nginxphp模块技巧_Nginx内置模块讲解

nginxphp模块技巧_Nginx内置模块讲解

访客 2024-10-31 0

扫一扫用手机浏览

文章目录 [+]

image.png

不仅仅是我圈中的那些,--with moudle的都是。
二、--with-http_stub_status_moudle

1、浸染

nginxphp模块技巧_Nginx内置模块讲解

Nginx的客户端状态

nginxphp模块技巧_Nginx内置模块讲解
(图片来自网络侵删)

2、配置语法

location /mystatus { stub_status;}

image.png

三、--with-http_random_index_moudle

1、浸染

目录中选择一个随机主页。

2、配置语法

location / { root /chentongwei/app/code/; random_index on;}

image.png

然后要求我们的nginx,会创造每次的输出结果不同。
是随机的(1.html/2.html/3.html)。

默认是off关闭的。

四、--with-http_sub_moudle

1、浸染

http内容更换。

2、配置语法

location / { root /chentongwei/app/code; index index.html index.htm; sub_filter 'ctw' '<h1>chentongwei</h1>';}

PS:

意思是将/chentongwei/app/code目录下的文件里的ctw字符串更换成<h1>chentongwei</h1>

我们有如下submoudle.html

[chentongwei@YY155 app]$ cat code/submoudle.html abcdctwefgctw

结果:

image.png

只更换了第一个匹配到的,并没有全部匹配。
若须要全部匹配,则关闭如下选项即可:

sub_filter_once off;默认是on。

关闭sub_filter_once后的配置

location / { root /chentongwei/app/code; index index.html index.htm; sub_filter 'ctw' '<h1>chentongwei</h1>'; sub_filter_once off;}

结果:

作者:编程界的小学生

链接:https://www.jianshu.com/p/373fd752076e

相关文章