使用“HTTP基本認(rèn)證”(HTTP Basic Authentication)協(xié)議的用戶名密碼驗(yàn)證。
1.location相關(guān)配置
location /report/m_report {
alias /opt/dfs/m_report;
include mime.types;
default_type application/octet-stream;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
auth_basic "input you user name and password";
auth_basic_user_file /home/report/m_report.passwd;
}
在對應(yīng)的server中配置 以上的location,可以通過auth-basic驗(yàn)證用戶。
2.生成用戶名和密碼
- 創(chuàng)建
auth_basic_user_file文件。htpasswd -c /home/report/m_report.passwd username - 增加用戶。
htpasswd -b /home/report/m_report.passwd username password