nginx配置只能查看图片

复制代码
1.在图片所在的目录下创建一个名为.htaccess’的隐藏文件,该文件用于设置禁止下载
2.在.htaccess文件中添加以下配置:
    SetHandler default-handler
  Options-Indexes

这样设置后,用户就无法通过点击链接或使用下载工具下载图片了
接下来,在 nginx的配置文件中添加以下配置
location /path/to/images/ {
add header Content-Disposition "inline";
add header Content-Type "image/jpeg";
}
此配置会为指定路径下的所有图片文件添加Content-Disposition’和Content-Type’头信息,使其只能在线查看。
最后,重启 nginx 服务器使配置生效
复制代码
复制代码
 location /pic {
               alias /data/;
               proxy_connect_timeout 3;
               proxy_read_timeout 3;
               proxy_send_timeout 3;
                autoindex on;
             add_header Content-Disposition "inline";
             add_header Content-Type "image/jpeg";
    }
复制代码

 

posted on   五官一体即忢  阅读(87)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示