基於HTTP Basic Authentication協議進行用戶名密碼認證
默認已經編譯進Nginx
安裝htpasswd,如果沒有,則手動安裝
yum install -y httpd-tools
生成用戶命名密碼文件
在nginx目錄下建立auth目錄,進入目錄,新建兩個用戶
htpasswd -b -c encrypt_pass jack 111111
htpasswd -b encrypt_pass rose 111111
vim nginx
location / {
root html;
index index.html index.htm;
auth_basic "測試basic功能";
auth_basic_user_file /usr/local/nginx/auth/encrypt_pass;
}