Nginx 模块

# 查看 Nginx 状态(请求数,处理数等)
--with-http_stub_status_module
Syntax: stub_status;
Default: -
Content: server,location



# 随机返回目录下的文件
--with-http_random_index_module
Syntax: random_index on|off;
Default: random_index off;
Content: location



# 替换内容(替换字符串,-,是否多次替换)
--with-http_sub_mobule
Syntax: sub_filter string replacement;
Default: -
Content: http,server,location

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

Syntax: sub_filter_once on|off;
Default: sub_filter_once off;
Content: http,server,location



# 连接频率限制,请求频率限制
limit_conn_module
limit_req_module

# 开辟空间,key作为限制,name是名字,size是申请空间的大小,如2兆,10兆
Syntax: limit_conn_zone key zone=name:size;
Default: -
Content: http

# 限制,zone是空间名字,number是同一时间的限制数
Syntax: limit_conn zone number;
Default: -
Contetn: http,server,location

# 开辟空间,key作为限制,name是名字,size是申请空间的大小,如2兆,10兆,rate定义好这个请求时多大单位,通常1秒
Syntax: limit_req_zone key zone=name:size rate=rate;
Default: -
Content: http

# 限制,name是空间名字
Syntax: limit_req zone=name [burst=number] [nodelay];
Default: -
Contetn: http,server,location

# 例子
http:
limit_conn_zone $binary_remote_addr zone=conn_zone:1m;
limit_req_zone $binary_remote_addr zone=req_zone:1m rate=1r/s;
server:
limit_conn conn_zone 1;
limit_req zone=req_zone burst=3 nodelay;



# Nginx的访问控制
基于IP的访问控制 - http_access_module
基于用户的信任登录 - http_auth_basic_module

http_access_mobule
Syntax: allow address | CIDR | unix: | all;
Default: -
Content: http,server,location,limit_except

Syntax: deny address | CIDR | unix: | all;
Default: -
Content: http,server,location,limit_except

http_auth_basic_module
Syntax: auth_basic string | off;
Default: auth_basic off;
Content: http,server,location,limit_except

Syntax: auth_basic_user_file file;
Default: -
Content: http,server,location,limit_except

htpasswd -c ./htpasswd admin