Nginx创建密码保护隐私区域

技术运维Nginx 336

passwd命令创建密码文件和用户管理请参考:

保护某个目录:

location ^~ /secret_folder/ {
auth_basic            "Restricted Area";
auth_basic_user_file  conf/htpasswd;
}

保护整个根目录

location / {
........................................
........................................
auth_basic            "Restricted Area";
auth_basic_user_file  conf/htpasswd;
}

Post Comment