首页 > 其他 > 详细

设置nginx列表下载文件并设置密码的配置

时间:2017-03-06 22:45:15      阅读:420      评论:0      收藏:0      [点我收藏+]

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/

输入密码就可以下载了


设置nginx列表下载文件并设置密码的配置

原文:http://chenshifei.blog.51cto.com/11883413/1903632

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!