Learn nginx authentication module auth_basic

The configuration is as follows:

server {
    
    

    listen          8085;
    root            /data/nginx/domain6;
    server_name     www.c.com;
    charset         utf-8;


    location        /   {
    
    
        root        /data/nginx/domain6;
    }

    location        ~* /images/  {
    
    
        root                   /data/nginx/domain6;
        auth_basic             "Private Zone";
        auth_basic_user_file   /data/nginx/domain6/ssl/.htpasswd;
        autoindex             on;



    }








}

Use the command to prepare the .htpasswd file

htpasswd -cmb .htpasswd username password
-c is used when creating a new .htpasswd, add
htpasswd -mb .htpasswd username2 password2

Access
Insert picture description here
user authentication input settings pop-up box, and a password.

Guess you like

Origin blog.csdn.net/weixin_45937255/article/details/115355537