10.用户认证模块(ngx_http_auth_basic_module)
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:当前状态,正在等待客户端发出请求的空闲连接数
- 原文作者:老鱼干🦈
- 原文链接://www.tinyfish.top:80/post/Linux_%E8%BF%90%E7%BB%B4/%E9%83%A8%E7%BD%B2%E7%BD%91%E7%AB%99%E6%9C%8D%E5%8A%A1%E5%99%A8/10.%E7%94%A8%E6%88%B7%E8%AE%A4%E8%AF%81%E6%A8%A1%E5%9D%97ngx_http_auth_basic_module/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. 进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。