tengine nginx IP访问控制 用户认证访问 访问状态

2017-07-20  本文已影响133人  ifcoder

IP访问控制

==规则:按照顺序依次检测,直到匹配到第一条规则==

location {
deny 192.168.1.109;
allow 192.168.1.0/24;allow IP/IP段;
deny all;
}

用户认证访问

模块ngx_http_auth_basic_module 允许使用“HTTP基本认证”协议验证用户名和密 码来限制对资源的访问。

location /{
   auth_basic "string"|off; //当描述符为off时,关闭该功能 
   auth_basic_user_file /var/users;
}

Apache发行包中的htpasswd命令来创建user_file 文件
htpasswd -cmb /var/users adn aidongning
==注:需要安装httpd才可以使用上面命令==

yum -y install httpd

htpasswd用法:

Usage:
    htpasswd [-cmdpsD] passwordfile username
    htpasswd -b[cmdpsD] passwordfile username password

    htpasswd -n[mdps] username
    htpasswd -nb[mdps] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -m  Force MD5 encryption of the password.
 -d  Force CRYPT encryption of the password (default).
 -p  Do not encrypt the password (plaintext).
 -s  Force SHA encryption of the password.
 -b  Use the password from the command line rather than prompting for it.
 -D  Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.

nginx访问状态监控

location /basic_status {
    stub_status on;
}
上一篇下一篇

猜你喜欢

热点阅读