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 不会覆盖直接的用户,密码需要直接跟在用户名后面
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。