美文网首页Nginx
Nginx几个小模块

Nginx几个小模块

作者: 燃燃的爸爸 | 来源:发表于2019-05-22 14:59 被阅读0次

一、http_stub_status
作用:Nginx的客户端状态
Syntax:stub_status
Default:- 默认没开启
Context:server,location
举例:

location /mystatus {
        stub_status;
    }

请求结果:


image.png

二、http_random_index(比较少用到)
作用:目录中选择一个随机主页
Syntax:random_index on | off;
Default:random_index off;
Context:location
注意 随机不会随机到隐藏文件如.3.html 是随机不到的。

三、http_sub_module
作用:http内容替换
Syntax:sub_filter string replacement;
Default:-
Context:http,server,location

Syntax:sub_filter_last_modified on | off;
Default:sub_filter_last_modified off;
Context:http,server,location

Syntax:sub_filter_once on | off;
Default:sub_filter_once on;
Context:http,server,location
案例:
新增两个标签


image.png

配置文件新增

root   /usr/share/nginx/html;
        index  index.html index.htm;
        sub_filter 'cf' 'xj'
image.png

可以发现已经有一个cf变替换成了xj,如果全部cf都要改成xj,再次添加参数sub_filter_once off;


image.png

相关文章

网友评论

    本文标题:Nginx几个小模块

    本文链接:https://www.haomeiwen.com/subject/awayzqtx.html