IP訪問控制
==規(guī)則:按照順序依次檢測,直到匹配到第一條規(guī)則==
location {
deny 192.168.1.109;
allow 192.168.1.0/24;allow IP/IP段;
deny all;
}
用戶認(rèn)證訪問
模塊ngx_http_auth_basic_module 允許使用“HTTP基本認(rèn)證”協(xié)議驗(yàn)證用戶名和密 碼來限制對資源的訪問萍虽。
location /{
auth_basic "string"|off; //當(dāng)描述符為off時(shí),關(guān)閉該功能
auth_basic_user_file /var/users;
}
Apache發(fā)行包中的htpasswd命令來創(chuàng)建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訪問狀態(tài)監(jiān)控
location /basic_status {
stub_status on;
}