基于主机(IP)
module ngx_http_access_moduledirectiver allow #允许 deny #拒接syntax #allow address |CIDR |UNIX: |ALL;Context: http,server,location,limit_except案例:server {allow 192.168.8.1;allow 192.168.7.*;deny all;}
基于用户 auth:认证 basic:基本
module ngx_http_auth_basic_modulesyntax: auth_basic_user_file file;Context: http,server,location,limit_excep#案列htpasswd -cm /etc/nginx/conf.d/passwd user10-c 创造-m 加密/etc/nginx/conf.d/passwd 创建到那个文件,如果有这个文件就可以不加 - c用那个网站就在那个网站创建#案例vim /etc/nginx/conf.d/default.confserver {auth_basic "欢迎来到身份验证页面:p"; #提示信息auth_basic_user_file /etc/nginx/conf.d/passwd ; #存密码}