4、用户认证模块(ngx_http_auth_basic_module)此模块使用HTTP Basic Authentication协议限制对资源的访问,通过用户名和密码方式。

auth_basicSyntax: auth_basic string | off;Default: auth_basic off;Context: http, server, location, limit_except激活和关闭认证功能。

auth_basic_user_fileSyntax: auth_basic_user_file file;Default: —Context: http, server, location, limit_except指定保存用户名和密码的文件。格式如下:

comment

name1:password1name2:password2:commentname3:password3

#也可以使用密文。可以通过使用apatch的htpasswd命令(http-tools提供)#或者openssl passwd命令配置案例:

location /admin/ {auth_basic “Admin Area”;auth_basic_user_file /etc/nginx/.ngxpasswd;}

location / {auth_basic           “closed site”;auth_basic_user_file conf/htpasswd;}5、基本状态查看模块(ngx_http_stub_status_module)提供对基本状态信息的访问

stub_statusSyntax: stub_status;Default: —Context: server, location在1.7.5之前的版本:“stub_status on”。配置案例:

location = /basic_status {stub_status;}

location /status {stub_status;allow 172.16.0.0/16;deny all;}

#用于输出nginx的基本状态信息#Active connections:当前状态,活动状态的连接数#accepts:统计总值,已经接受的客户端请求的总数#handled:统计总值,已经处理完成的客户端请求的总数#requests:统计总值,客户端发来的总的请求数#Reading:当前状态,正在读取客户端请求报文首部的连接的连接数#Writing:当前状态,正在向客户端发送响应报文过程中的连接数#Waiting:当前状态,正在等待客户端发出请求的空闲连接数