一、Nginx實戰之讓用戶經過用戶名密碼認證訪問web站點html
[root@master ~]# vim /usr/local/nginx/conf/extra/www.conf server { listen 80; //監聽端口爲80 server_name www.test.com; //虛擬主機網址 location / { root html/; //虛擬主機網站根目錄 index index.html index.htm; //虛擬主機首頁 auth_basic "secret"; //虛擬主機認證命名 auth_basic_user_file /usr/local/nginx/passwd.db; //虛擬主機用戶名密碼認證數據庫 } location /status { stub_status on; //開啓網站監控狀態 access_log /usr/local/nginx/logs/www1_status.log; //監控日誌 auth_basic "NginxStatus"; } }
[root@master extra]# htpasswd -c /usr/local/nginx/passwd.db admin New password: Re-type new password: Adding password for user admin [root@abcdocker extra]# chmod 400 /usr/local/nginx/passwd.db [root@abcdocker extra]# chown nginx. /usr/local/nginx/passwd.db [root@abcdocker extra]# cat /usr/local/nginx/passwd.db admin:$apr1$w3RqjNXW$mSiazU7t2THQqo3LrPmlP/