你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

Nginx登录验证

2021/12/19 0:35:57
  1. auth模块 默认已开启
  2. 生成账号
➜  ~ printf "ogenes:$(openssl passwd -crypt 888888)\n" >> account
➜  ~ cat account
ogenes:ddiY8Imto3UaA
  1. 配置
    location / {
        auth_basic "Please enter your username and password";
        auth_basic_user_file account;
        autoindex on;
        ……
    }
  1. 重启
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ nginx -s reload
  1. 测试

    image.png