cd /etc/nginx/conf.d
创建密码文件和用户密码
htpasswd -c .htpasswd fileuser_chenshifei
输入密码
vim default.conf
配置文件
server {
listen 80 default_server;
#listen [::]:80 default_server;
server_name _;
#root /usr/share/nginx/html;
root /var/www/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
#列表
autoindex on;
#隐藏真实大小,以M或G显示
autoindex_exact_size off;
#显示时间
autoindex_localtime on;
#设置密码文件
auth_basic "input you user name and password";
auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
将文件包放在/var/www/html下
nginx -s reload
访问ip:80/
输入密码就可以下载了
转载于:https://blog.51cto.com/chenshifei/1903632