簡單的實現HTTP密碼驗證登陸


1.首先需要安裝 httpd-tools

yum install -y httpd-tools

 

2.安裝完成后設置用戶名密碼,我這里用的是NGINX  

   htpasswd -bc /mypath/nginx/conf/htpasswd.users admin(注:用戶名) 123456(注:密碼)

3. 修改nginx的配置:

 
        
server {
        listen       80;
        server_name  elk.log.com;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

       auth_basic "Restricted Access";
       auth_basic_user_file /mypath/nginx/conf/htpasswd.users;      #登錄驗證
       location / {

           proxy_pass http://127.0.0.1:5601;     #轉發到你指定的域名或IP
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection 'upgrade';
           proxy_set_header Host $host;
           proxy_cache_bypass $http_upgrade;
           allow 192.168.0.1;  #允許的IP
           allow 118.133.10.6; #允許的IP
           deny all;
       }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM