Nginx configurations and problem solves

  1. Nginx configure
    1. Nginx directory auth setting

Nginx configure

Nginx directory auth setting

https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/

apt install apache2-utils -y
yum install httpd-tools -y

sudo htpasswd -c /etc/apache2/.htpasswd user1 # -c create new file
location /api {
    auth_basic           "Administrator Area";
    auth_basic_user_file /etc/apache2/.htpasswd; 

    satisfy all; # allow if pass all rule
    satisfy any; # allow if pass any rule

    deny  192.168.1.2;
    allow 192.168.1.1/24;
    allow 127.0.0.1;
    deny  all;
}
nginx -s reload