AWS S3 Website Https : Amazon S3 Website Endpoints Examples

AWS S3 Website Https : Amazon S3 Website Endpoints Examples

You can use Amazon S3 to host a static website. On a static website, individual webpages include static content. They might also contain client-side scripts.

By contrast, a dynamic website relies on server-side processing, including server-side scripts such as PHP, JSP, or ASP.NET. Amazon S3 does not support server-side scripting, but AWS has other resources for hosting dynamic websites

You can use the AWS Amplify Console to host a single page web app. The AWS Amplify Console supports single page apps built with single page app frameworks (for example, React JS, Vue JS, Angular JS, and Nuxt) and static site generators (for example, Gatsby JS, React-static, Jekyll, and Hugo).

Website endpoints

When you configure your bucket as a static website, the website is available at the AWS Region-specific website endpoint of the bucket. Website endpoints are different from the endpoints where you send REST API requests.

Depending on your Region, your Amazon S3 website endpoint follows one of these two formats

  • s3-website dash (-) Region ‐ http://bucket-name.s3-website-Region.amazonaws.com
  • s3-website dot (.) Region ‐ http://bucket-name.s3-website.Region.amazonaws.com

These URLs return the default index document that you configure for the website

For your customers to access content at the website endpoint, you must make all your content publicly readable. To do so, you can edit the S3 Block Public Access settings for the bucket. Then, use a bucket policy or an access control list (ACL) on an object to grant the necessary permissions

Important

Amazon S3 website endpoints do not support HTTPS or access points. If you want to use HTTPS, you can use Amazon CloudFront to serve a static website hosted on Amazon S3.

Requester Pays buckets do not allow access through a website endpoint. Any request to such a bucket receives a 403 Access Denied response.

Amazon Prime

Website endpoint examples

The following examples show how you can access an Amazon S3 bucket that is configured as a static website.

Example — Requesting an object at the root level

To request a specific object that is stored at the root level in the bucket, use the following URL structure.

http://bucket-name.s3-website.Region.amazonaws.com/object-name

For example, the following URL requests the photo.jpg object that is stored at the root level in the bucket.

http://example-bucket.s3-website.us-west-2.amazonaws.com/photo.jpg

Example — Requesting an object in a prefix

To request an object that is stored in a folder in your bucket, use this URL structure.

http://bucket-name.s3-website.Region.amazonaws.com/folder-name/object-name

The following URL requests the docs/doc1.html object in your bucket.

http://example-bucket.s3-website.us-west-2.amazonaws.com/docs/doc1.html

Adding a DNS CNAME

If you have a registered domain, you can add a DNS CNAME entry to point to the Amazon S3 website endpoint. For example, if you registered the domain www.example-bucket.com, you could create a bucket www.example-bucket.com, and add a DNS CNAME record that points to www.example-bucket.com.s3-website.Region.amazonaws.com. All requests to http://www.example-bucket.com are routed to www.example-bucket.com.s3-website.Region.amazonaws.com.

Using a custom domain with Route 53

Instead of accessing the website using an Amazon S3 website endpoint, you can use your own domain registered with Amazon Route 53 to serve your content—for example, example.com. You can use Amazon S3 with Route 53 to host a website at the root domain. For example, if you have the root domain example.com and you host your website on Amazon S3, your website visitors can access the site from their browser by entering either http://www.example.com or http://example.com.

Leave a Reply

Your email address will not be published. Required fields are marked *