美文网首页
Ubuntu利用Nginx配置下载站点,带加密模块auth_ba

Ubuntu利用Nginx配置下载站点,带加密模块auth_ba

作者: 梨花菜 | 来源:发表于2019-03-02 14:55 被阅读0次

    Nginx配置

    server{
            listen 80;
            server_name 44.186.148.233;# 本机 ip
                    location /down {
                    root /home/lihuacai168; # 访问根目录,访问35.186.148.232/down 相当于访问/home/lihuacai168/down.
                    # alias  /home/lihuacai168/; #访问35.186.148.232/down 相当于访问 /home/lihuacai168/,这个目录下面不需要有down文件夹
                    autoindex on;
                    autoindex_localtime on;
                    autoindex_exact_size off;
                    charset utf-8;
                    auth_basic "请输入密码";
                    auth_basic_user_file /etc/nginx/pass_file; # 存放密码文件的路径
                    }
         }
    

    安装httpd 密码文件管理工具

    apt install apache2-utils
    

    生成密码

     htpasswd -c -d /etc/nginx/pass_file  username # -c 会覆盖掉之前生成的用户
     htpasswd -b -d /etc/nginx/pass_file  username password123 # -b 不会覆盖直接的用户,密码需要直接跟在用户名后面
    
    
    

    相关文章

      网友评论

          本文标题:Ubuntu利用Nginx配置下载站点,带加密模块auth_ba

          本文链接:https://www.haomeiwen.com/subject/fsieuqtx.html