Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Prevent direct download of photos/video files from amazon s3

You can restrict access based on the HTTP referrer. It’s not bulletproof (Referrer can be spoofed) but it will stop casual downloads.

Suppose you have a website with domain name (www.devopsschool.com or devopsschool.com) with links to photos and videos stored in your S3 bucket, examplebucket. By default, all the S3 resources are private, so only the AWS account that created the resources can access them. To allow read access to these objects from your website, you can add a bucket policy that allows s3:GetObject permission with a condition, using the aws:Referer key, that the get request must originate from specific webpages. The following policy specifies the StringLike condition with the aws:Referer condition key.

{
  "Version":"2012-10-17",
  "Id":"http referer policy example",
  "Statement":[
    {
      "Sid":"Allow get requests originating from www.example.com and example.com.",
      "Effect":"Allow",
      "Principal":"*",
      "Action":"s3:GetObject",
      "Resource":"arn:aws:s3:::examplebucket/*",
      "Condition":{
        "StringLike":{"aws:Referer":["http://www.example.com/*","http://example.com/*"]}
      }
    }
  ]
}Code language: JSON / JSON with Comments (json)

You can further secure access to objects in the examplebucket bucket by adding explicit deny to the bucket policy as shown in the following example. Explicit deny supersedes any permission you might grant to objects in the examplebucket bucket using other means such as ACLs or user policies.

{
   "Version": "2012-10-17",
   "Id": "http referer policy example",
   "Statement": [
     {
       "Sid": "Allow get requests referred by www.example.com and example.com.",
       "Effect": "Allow",
       "Principal": "*",
       "Action": "s3:GetObject",
       "Resource": "arn:aws:s3:::examplebucket/*",
       "Condition": {
         "StringLike": {"aws:Referer": ["http://www.example.com/*","http://example.com/*"]}
       }
     },
      {
        "Sid": "Explicit deny to ensure requests are allowed only from specific referer.",
        "Effect": "Deny",
        "Principal": "*",
        "Action": "s3:*",
        "Resource": "arn:aws:s3:::examplebucket/*",
        "Condition": {
          "StringNotLike": {"aws:Referer": ["http://www.example.com/*","http://example.com/*"]}
        }
      }
   ]
}
Code language: JSON / JSON with Comments (json)
{
  "Id": "Policy1560396001395",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1560395998201",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::devops-t1/*",
      "Condition": {
        "StringLike": {
          "aws:Referer": "https://www.devopsschool.com/*"
        }
      },
      "Principal": "*"
    }
  ]
}
Code language: JSON / JSON with Comments (json)
{
    "Version": "2008-10-17",
    "Id": "http referer policy example",
    "Statement": [
        {
            "Sid": "Allow get requests originated from www.example.com and example.com",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::devopsschoolmumbai/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": [
                        "https://www.devopsschool.com/*",
                        "https://devopsschool.com/*",
                        "https://devopsschool.com*",
                        "https://devopsschool.com"
                    ]
                }
            }
        }
    ]
}
Code language: JSON / JSON with Comments (json)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

AWS CLI Credentials Setup: Configure, Verify, and Secure Access

Learn how to configure AWS credentials with the AWS CLI, verify your identity, and understand where credentials are stored. This updated guide also compares profiles, environment variables, and role-based access.

Read More

Provision an AWS EC2 Instance with Chef (Legacy ChefDK Workflow)

A practical, step-by-step walkthrough for provisioning an AWS EC2 VM using the classic ChefDK and chef-provisioning approach. Includes workflow, commands, recipe examples, and validation checks for legacy environments.

Read More

EC2 Boot from EBS Explained: Architecture, Trade-offs, and an AWS CLI Workflow

Booting Amazon EC2 instances from Amazon EBS was a major shift from ephemeral root disks to persistent root volumes. This guide explains what changed, why it mattered, and how to use the model safely in modern operations.

Read More

Deploying Java EE on Amazon EC2 with EC2Deploy: Workflow, Script, and Modern Lessons

This revised guide breaks down the original EC2Deploy approach for provisioning EC2 instances, deploying Java EE apps, and running JMeter tests. It also maps the same deployment pattern to modern DevOps practices.

Read More

EC2Deploy and the Cloud Tools Maven Plugin: Architecture, Goals, and Deployment Workflow

This revised guide explains what the 2010 EC2Deploy and Cloud Tools release actually introduced, how its components fit together, and how the Maven goals map to deployment operations on EC2. It also covers what modern teams should verify before relying on this legacy toolchain.

Read More

Cloud Tools Adds Amazon EBS Support: Durable EC2 Storage for Database Workloads

This historical update covers when Cloud Tools introduced Amazon EBS support for EC2 applications, including database-backed deployments. It explains the supported storage modes, the backup/restore flow, and practical command-level equivalents.

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Tim
Tim
3 years ago

Thank you, that worked perfectly.

1
0
Would love your thoughts, please comment.x
()
x