# nginx搭建http文件服务器

249 阅读1分钟

1、开启文件下载配置

autoindex on;
autoindex_exact_size on;
autoindex_localtime on; 

2、授权访问指定的目录

2.1 安装htpasswd

yum -y install httpd-tools

2.2 创建密码文件

htpasswd -c /usr/local/file/.htpasswd test 按回车,输入密码

2.3 修改nginx配置

 auth_basic "请输入用户名和密码";
 auth_basic_user_file /usr/local/file/.htpasswd;