用戶認證

*******首先用戶認證是在ngixn裏的配置文件裏修改*******
/usr/local/nginx/conf/nginx.conf
1,文本進入配置文件裏的網頁(server)添加  *認證提示符和認證密碼文件*
server {
        listen       80;
        server_name  localhost;
        auth_basic      "Input Password:";                        //認證提示符
        auth_basic_user_file       "/usr/local/nginx/pass";    (路徑這裏可以隨意寫)認證密碼文件
wq

2,要在機器上安裝了httpd-tools 才能在命令行執行htpasswd命令!!  (可以雙擊tab列出httpd有關安裝包)
2.1,使用htpasswd創建賬戶文件體系(整個流程包含了建立用戶名和密碼)
[proxy]  yum -y install httpd-tools  安裝必須有的包 
[proxy]  htpasswd  -c  /usr/local/ngixn/pass    tom    (路徑需跟上一步的認證密碼文件路徑一樣!!)
New password: 
Re-type new password: 
Adding password for user tom
在次創建賬戶文件時不用加   -c
htpasswd  /usr/local/nginx/pass   jerry
3,查看你創建的用戶名密碼是否已經生成!
[proxy] cat   /usr/local/nginx/pass
不想要用戶可以直接進入 vim   /usr/local/nginx/pass 雙擊dd刪除
4, 重新加載 nginx服務
nginx -s  reload
5,客戶端測試
[root@client ~] firefox http://192.168.4.5

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章