简体   繁体   English

S3策略停止热链接?

[英]S3 policy to stop hotlinking?

Our current S3 policy reads as: 我们当前的S3政策内容如下:

{
"Version": "2008-10-17",
"Id": "45103629-690a-4a93-97f8-1abe2f9bb68c",
"Statement": [
    {
        "Sid": "AddPerm",
        "Effect": "Allow",
        "Principal": {
            "AWS": "*"
        },
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::incredibad29/*"
    }
]
}

This just allows anyone to access files from within. 这仅允许任何人从内部访问文件。

We want to add a hotlinking statement, so users can ONLY acccess the file if referred from our site. 我们要添加一个热链接语句,因此,如果从我们的网站引用,则用户只能访问该文件。 So from a domain starting with incredibad29.com or www.incredibad.com 因此,从以incredibad29.com或www.incredibad.com开头的域中

I just can't figure out how to do this. 我只是不知道如何做到这一点。 Any help would be amazing, thank you! 任何帮助都将是惊人的,谢谢!

If it is for images and other media types, there is a known hack that uses content type headers: 如果用于图像和其他媒体类型,则存在使用内容类型标头的已知黑客:

There's a workaround that you may use to block hotlinking of selective images and files that you think are putting a major strain in your Amazon S3 budget. 您可以使用一种变通办法来阻止选择性镜像的图像和文件的热链接,您认为这对Amazon S3预算造成了很大压力。 When you upload a file to your Amazon S3 account, the service assigns a certain Content-Type to every file based on its extension. 当您将文件上传到您的Amazon S3帐户时,该服务会根据文件的扩展名为每个文件分配特定的Content-Type。 For instance, a .jpg file will have the Content-Type set as image/jpg while a .html file will have the Content-Type as text/html. 例如,.jpg文件的Content-Type设置为image / jpg,而.html文件的Content-Type设置为text / html。 A hidden feature in Amazon S3 is that you can manually assign any Content-Type to any file, irrespective of the file's extension, and this is what you can use to prevent hotlinking. Amazon S3的一个隐藏功能是,您可以手动将任何Content-Type分配给任何文件,而不管文件的扩展名如何,这就是您可以用来防止热链接的方法。

From: http://www.labnol.org/internet/prevent-image-hotlinking-in-amazon-s3/13156/ 来自: http : //www.labnol.org/internet/prevent-image-hotlinking-in-amazon-s3/13156/


I think this is pretty much the basic technique. 我认为这几乎是基本技术。 However, if you skim the 6350 results for ` google s3 hotlinking deny you might find alternative ways :) 但是,如果您略过` google s3 hotlinking否认 6350结果,您可能会发现其他方法:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM