这篇文章主要介绍了 关于nginx常用的官方模块,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
Nginx常用官方模块
Nginx采用模块化的架构,Nginx中大部分功能都是通过模块方式提供的,比如HTTP模块、Mail模块等。
Nginx官方模块文档
1. ngx_http_stub_status_module
编译选项
--with-http_stub_status_module
作用
提供Nginx当前处理连接等基本状态信息的访问
语法
Syntax: stub_status; Default: — Context: server, location
用法
在nginx配置文件中的 server 下配置
server {
# 添加的配置
location /nginx_status {
stub_status;
}
...其它代码省略...
}修改后重新载入配置文件
nginx -s reload在浏览器中访问
http://,会返回如下内容/nginx_status
Active connections: 3 server accepts handled requests 7 7 16 Reading: 0 Writing: 1 Waiting: 2
Active connections: Nginx当前活跃链接数accepts: 接收客户端连接的总次数handled: 处理客户端连接的总次数。一般来说,这个参数值与accepts相同,除非已经达到了一些资源限制(例如worker_connections限制)requests: 客户端请求的总次数Reading: 当前nginx正在读取请求头的连接数Writing: 当前nginx正在写入响应的连接数Reading: 当前正在等待请求的空闲客户端连接数。一般是在nginx开启长连接(keep alive)情况下出现。
2. ngx_http_random_index_module
编译选项
--with-http_random_index_module
作用
在主目录中选择一个随机文件作为主页
语法
Syntax: random_index on | off; Default: random_index off; Context: location
用法
在nginx配置文件中的 server 下配置
server {
location / {
root /usr/share/nginx/html;
#添加这一行开启随机主页模块
random_index on;
#把指定的主页注释掉
#index index.html index.htm;
}
...其它代码省略...
}3. ngx_http_sub_module
编译选项
--with-ngx_http_sub_module
作用
通过替换一个指定的字符串来修改响应
语法
指定被替换的字符和替代字符
Syntax: sub_filter string replacement; Default: — Context: http, server, location
Last-Modified,用于校验服务端内容是否更改,主要用于缓存场景
Magento是一套专业开源的PHP电子商务系统。Magento设计得非常灵活,具有模块化架构体系和丰富的功能。易于与第三方应用系统无缝集成。Magento开源网店系统的特点主要分以下几大类,网站管理促销和工具国际化支持SEO搜索引擎优化结账方式运输快递支付方式客户服务用户帐户目录管理目录浏览产品展示分析和报表Magento 1.6 主要包含以下新特性:•持久性购物 - 为不同的
Syntax: sub_filter_last_modified on | off; Default: sub_filter_last_modified off; Context: http, server, location
默认只替换找到的第一个字符串,若替换文本中的所有匹配的字符串,则置为off
Syntax: sub_filter_once on | off; Default: sub_filter_once on; Context: http, server, location
除了“text/html”之外,还可以用指定的MIME类型替换字符串。特殊值‘*’匹配任意MIME类型
Syntax: sub_filter_types mime-type ...; Default: sub_filter_types text/html; Context: http, server, location
用法
在nginx配置文件中的 server 下配置
server {
location / {
root /usr/share/nginx/html;
index index.html;
# 将首页的nginx替换为home
sub_filter 'nginx' 'home';
# 不止替换第一个,而是替换response中所有的nginx
sub_filter_once off;
}
...其它代码省略...
}修改后重新载入配置文件
nginx -s reloadcurl localhost,返回如下内容,会发现响应中所有nginx已经替换为home
[vagrant/etc/nginx]$ curl localhostWelcome to home! Welcome to home!
If you see this page, the home web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to home.org.
Commercial support is available at home.com.Thank you for using home.
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:









