【问题标题】:Apache directory and security for the images图像的 Apache 目录和安全性
【发布时间】:2012-03-06 17:08:27
【问题描述】:

基本上,Apache 目录中的所有文件都无法访问,除了图像。图像应该是可访问的,但前提是通过网站加载。 如果我根据referer设置Apache规则很容易绕过:http://www.mustap.com/phpzone_post_62_how-to-bypass-the-referer-se 这当然不是正确的选择。

我的 Apache 配置文件:

<Directory /var/www/path>
    Order allow,deny
    Deny from all
    Options -Indexes
    # Check against the referer, first level check
    SetEnvIf Referer domain1\.com domain1
    SetEnvIf Referer domain1\.com domain2
    <FilesMatch \.(jpg|jpeg|gif|png)$>
        Order deny,allow
        Deny from all
        Allow from env=domain1
        Allow from env=domain2
    </FilesMatch>
</Directory>

如何在不将图像放入数据库的情况下解决此问题?

谢谢

【问题讨论】:

    标签: php apache referer


    【解决方案1】:

    确定的一种方法是通过 PHP 脚本运行所有图像,该脚本使用 readfile() 之类的东西来检查请求的图像,然后将其输出。

    例如:site.com/image.php?name=logo.jpg

    该脚本可以检查用户是否在您的网站上进行了会话,如果没有,则表示他们在没有先查看网站的情况下请求图像(除非禁用 cookie)。

    但这会增加加载时间,因此您必须考虑实施的成本/收益。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-24
    • 1970-01-01
    • 2010-10-16
    • 2020-08-27
    • 2021-04-10
    • 1970-01-01
    相关资源
    最近更新 更多