Apache目录和映像的安全性


Apache directory and security for the images

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

我的Apache conf文件:

<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脚本运行所有图像,该脚本使用类似readfile()的东西来检查请求的图像,然后输出它。

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

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

这将增加加载时间,因此您必须考虑实现的成本/效益。