Logo

dev-resources.site

for different kinds of informations.

AWS S3 Change Url, Proxy Url, Map to Domain in 2024

Published at
11/22/2024
Categories
aws
s3
url
dns
Author
greggcbs
Categories
4 categories in total
aws
open
s3
open
url
open
dns
open
Author
8 person written this
greggcbs
open
AWS S3 Change Url, Proxy Url, Map to Domain in 2024

It is not hard to map your ugly s3 url to your domain so you can have nice urls to share with your customers.

I will take you to this
https://files.utickets.co.za/media_wHIuV57H_i5XWqS3KN.jpg

from this
https://s3.eu-west-2.amazonaws.com/files.utickets.co.za/media_wHIuV57H_i5XWqS3KN.jpg

https://files.utickets.co.za.s3.eu-west-2.amazonaws.com/media_wHIuV57H_i5XWqS3KN.jpg

Its easy so dont stress. Get it working and then you can refine from there. I recommend you experiment with a new bucket.

Steps Outline

  1. create a bucket with your domain in the name
  2. add the usual bucket policy to make your files accessible
  3. add the usual cors permissions to make your bucket files accessible
  4. add a cname dns entry into your domain manager

Steps

1: Your bucket name needs to have your domain in it, for example your bucket name can be "yoursite.com", "assets.yoursite.com", "files.yoursite.com", "cdn.yoursite.com" - whatever you want.

2: Copy and paste or set your own bucket permissions that you want. Here is the Bucket policy for public accessibility, swop out bucket name for your bucket name (the files.yoursite.com parts):

{
    "Version": "2012-10-17",
    "Id": "PolicyForCloudFrontPrivateContent",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::files.yoursite.com/*"
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

3: Copy and paste the Cross-origin resource sharing (CORS) or set/use your own:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]
Enter fullscreen mode Exit fullscreen mode

4: In your domain manager where you manage your website domain DNS etc you will need to add a cname record that will map your custom url to s3's url.

I get the s3 url by uploading an image into the bucket and then viewing the image and copying its url.

The url will look like this (not exactly what we expect)
https://s3.eu-west-2.amazonaws.com/files.utickets.co.za/media_wHIuV57H_i5XWqS3KN.jpg

You can actually cut and paste your bucket name to the front of the url and it works:
https://files.utickets.co.za.s3.eu-west-2.amazonaws.com/media_wHIuV57H_i5XWqS3KN.jpg

Then in your DNS manager add your cname entry like so:
host: files.yoursite.com
value: files.yoursite.co.za.s3.eu-west-2.amazonaws.com

Save it and wait for it to take affect. Now you have beautiful urls.

If you try and view your bucket files through your new url and it throws a permission error, this is because your permission policy or cors might be blocking it, you will need to try the open policies I have given and then work from there.

Thanks for reading! I hope this helped.

dns Article's
30 articles in total
Favicon
Building and Deploying a New API (Part 3)
Favicon
Configuring a custom domain for your Azure Static Web App
Favicon
วิธีติดตั้งและกำหนดค่าเบื้องต้นสำหรับเซิร์ฟเวอร์ DNS บน Ubuntu 22.04 LTS แบบง่าย ๆ
Favicon
Email Verifier using Go
Favicon
What are DNS records?
Favicon
How to understand the ins and outs of how DNS really works.
Favicon
How to Simplify DNS Management in a Multi-Account Environment with Route 53 Resolver
Favicon
How to Add an Elastic (Static) IP to Your EC2 Instance And Update Your DNS Records on Route53
Favicon
DNS Spoofing: Controlling DNS Requests on the Network
Favicon
DHCP dinamik DNS güncellemesi
Favicon
Migrate a hosted zone to a different AWS account in few seconds!!
Favicon
Explaining DNS NXDOMAIN status in SOA Record Type: On Non-Existing Domains
Favicon
Instant Domain Insights: Why Every Tech Professional Needs DNS Checker Pro
Favicon
Automating DNS Management in Kubernetes with ExternalDNS
Favicon
DNS-load-balancing
Favicon
Verify your Bluesky or Mastodon account on your own domain, with a free website!
Favicon
How to Install and Configure a Private BIND DNS Server on Ubuntu 22.04
Favicon
How to Add DNS Records for Your Domain in Route53
Favicon
AWS S3 Change Url, Proxy Url, Map to Domain in 2024
Favicon
From WHOIS to SSL: How DNS Checker Pro Unveils the Hidden Details of Any Website
Favicon
Automating AWS DNS Firewall Domain List Updates Using S3, Lambda, and CLI
Favicon
Explaining CAA DNS Record
Favicon
Mastering DNS Spoofing with Bettercap: A Comprehensive Guide
Favicon
Issue 65 of AWS Cloud Security Weekly
Favicon
Unlocking the Internet's Address Book: DNS Roots Explained!
Favicon
I bought us-east-1.com: A Look at Security, DNS Traffic, and Protecting AWS Users
Favicon
Unlocking the Power of AWS Route 53: Your Complete Guide to DNS Management
Favicon
DNS: More Than Just a Web Directory
Favicon
Automating DNS with Confidence: Terraform + DNScontrol
Favicon
"Message Not Delivered" - What to Do When Your Email Bounces Back?

Featured ones: