1. 安裝 htpasswd 工具
yum -y install httpd-tools
2. 創(chuàng)建認(rèn)證用戶(hù)
htpasswd -c pass.db wang //wang 并輸入密碼
在次添加用戶(hù)時(shí)輸入時(shí)輸入
htpasswd pass.db username
會(huì)在/etx/nginx/passwd.db文件中生成用戶(hù)名和加密的密碼:
myuser:YlmaHlkJnzhxG
3.nginx 增加兩項(xiàng)配置:
增加 auth_basic 和 auth_basic_user_file
vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name local.server.com;
**auth_basic "User Authentication";
auth_basic_user_file /etc/nginx/pass.db;**
location / {
root /data/www;
index index.html;
}
}
4 . 重啟nginx服務(wù)
nginx -s reload
登錄頁(yè)面的時(shí)候就會(huì)顯示輸入用戶(hù)名密碼
file
<a >點(diǎn)擊該鏈接,獲取博客解鎖驗(yàn)證碼</a>