ubuntu系统 使用htpasswd创建用户名和密码文件 配置nginx认证

输入命令:htpasswd -c /***/.test  user

然后根据提示输入密码就可以了

nginx配置

server {
  listen 9999;
  server_name localhost;

  charset utf-8;
  location / {
    root /***/;
              auth_basic "Login";
    auth_basic_user_file /***/test;
              autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
  }
}

原文地址:https://www.cnblogs.com/zhangxuanblog/p/11842049.html