nginx 目录浏览

    xiaoxiao2023-03-24  3

    需求:现在文件已经归档到NAS存储上,但是相对于服务器而言,只是挂载到本地目录,因此,需要使用nginx方式提供可视化的下载

     

    一、使用nginx浏览目录

    配置方法如下

    location /huangbiao/ { alias /home/data/; #指名浏览目录 autoindex on; #开启nginx目录浏览功能 autoindex_exact_size off; #文件大小从KB开始显示 autoindex_localtime on; #显示文件修改时间为服务器本地时间 }

     

     

    二、Nginx设置目录浏览并配置验证

    1、在nginx/conf/nginx.conf中添加配置

     

    location /huangbiao/ { auth_basic “hb123456”;#中间不能有空格 auth_basic_user_file /tmp/htpasswd;#指名密码账号文件,不能为.htpasswd alias /home/; #指名浏览目录 autoindex on; #开启nginx目录浏览功能 autoindex_exact_size off; #文件大小从KB开始显示 autoindex_localtime on; #显示文件修改时间为服务器本地时间 }  

     

     2、添加账号密码文件/tmp/htpasswd

     [root@eccs_web tmp]# ls

    hsperfdata_root  htpasswd

    备注:htpasswd 文件使用Apache的htpasswd命令创建,请参考

    http://hbiao68.iteye.com/blog/2165087

    [Apache Home]\bin目录,输入命令

    htpasswd -c F:\hello\.htpasswd hb

     

    转载请注明原文地址: https://ju.6miu.com/read-1200156.html
    最新回复(0)