Nginx official module
You can view the parameters compiled by nginx -V, which we compiled modules included
limit_conn_module
Connection frequency limit
key: simply more conditions such as latitude REMOTE_ADDR
zone = name: size: zone configuration and application name space, size is the size of space applications of 1M 2M 10M
Syntax:limit_conn_zone key zone=name:size;
Default:–
Context:http
zone need to call the name of the application zone; limit the number of concurrent number such as 1 the same time only allowed one
Syntax: limit_conn zone number;
Defauly: -
Context: HTTP, Server, Localtion
limit_conn_zone $binary_remote_addr zone=conn_zone:1m;
server{
...
location / {
root /opt/app/code;
#限制服务端同一时刻只允许一个ip连接
limit_conn conn_zone 1;
}
...
}
limit_req_module
Request frequency limit
Syntax:limit_req_zone key zone=name:size rate=rate;
Default:–
Context:http
Syntax:limit_req zone=name [burst=number] [nodelay]
Default: –
Context:http,server,location
# 对于同一个客户端ip地址,所有的请求限制只允许在1s内发起一个
# $binary_remote_addr 和 remote_addr 区别在于 remote_addr要比binary_remote_addr多10个字节
limit_req_zone $binary_remote_addr zone=req_zone:1m rage=1r/s;
server{
...
location / {
root /opt/app/code;
limit_req zone=req_zone;
# 客户端在超过指定速率后,遗留的3个后一秒执行,其他的直接返会503
limit_req zone=req_zone burst=3 nodelay;
...
}
}
stub_status_module
Nginx connection status display
Syntax: stub_status;
the Default: -
the Context: Server, Localtion
location /mystatus {
stub_status;
}
random_index_module
Syntax:random_index on|off;
Default:random_index off;
Context:location
location / {
random_index on;
}
sub_module
http内容替换
Syntax:sub_filter string replacement;
Default: –
Context:http,server,location
If there is no update to determine whether the update is mainly used for the return of the original cache
Syntax: sub_filter_last_modified String Replacement;
the Default: sub_filter_last_modified OFF;
Context: HTTP, Server, LOCATION
on only match the first string match and replace all off
Syntax: sub_filter_once on | off;
the Default: sub_filter_once on;
Context: HTTP, Server, LOCATION
localtion / {
# 将第一个 daichen 替换为 daichen okok
sub_filter 'daichen daichen' 'daichen okok';
# 将所有daichen 替换为 daichen okok
sub_filter_once off; # 默认是on 改成off则开启全部匹配
}