【摘自张宴的"实战:Nginx"】http auth baseic模块(打开页面需要密码验证)

location /admin {
auth_basic "kingsoft";
auth_basic_user_file httppasswd;      #密码文件的路径  默认在/usr/local/nginx/conf,密码加密使用crypt
}

密码文件的格式:

账号:密码:备注

例如:


jack:$1$1xLSlxSV$f0M5xGIQ5iQJ7gpuWq26a0:test

jack:$1$1xLSlxSV$f0M5xGIQ5iQJ7gpuWq26a0:test2222

原文地址:https://www.cnblogs.com/maxomnis/p/5542471.html