Bref: Document HTTPS URLs for S3 assets

Created on 5 May 2019  路  6Comments  路  Source: brefphp/bref

I discovered via a discussion on Twitter that S3 exposes URLs that support HTTPS.

See this related question for more context: https://serverfault.com/questions/965935/what-are-the-differences-between-all-the-s3-urls

The URL format is much simpler as well: https://<bucket>.s3.amazonaws.com/<file> (no need for the region).

The documentation should be updated to use these new URLs.

Warning: I have no idea if these alternative URLs are compatible with custom domains. Also I don't know if these work with static website hosting too (if they serve index.html). It might be worth checking.

documentation help wanted

All 6 comments

A few things to note:

  • If you host your website (index.html) on S3, custom domain wouldn't work over HTTPS because the certificate wouldn't match. You would need CloudFront + Custom Domain + Custom Certificate. However, if you host index.php on a Lambda function and configure your project to load assets from S3 domain, you would be able to still have your php site on a custom domain while loading assets from non-custom domain.
  • Non Regional Links only work in Regions that existed before 2019. In other words, any new AWS Region launched this year and forward will not provide non-regional bucket domains. We may look at this as a sign that some day (probably many years from now) AWS might drop support for non-regional S3 access. (https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html).

:+1: thank you!

I got an answer on ServerFault:

  • https://<bucket>.s3.amazonaws.com/<file> and the now deprecated https://s3.<region>.amazonaws.com/<bucket>/<file> are REST endpoints
  • http://<bucket>.s3-website-<region>.amazonaws.com/<file> is the website endpoint and supports only HTTP

Capture d鈥檈虂cran 2019-05-05 a虁 20 05 17

https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff

I confirm that https://<bucket>.s3.amazonaws.com/<file> URLs works as CloudFront origins as well.

FYI, when your bucket name contains dots, the HTTPS version does not work. The certificate is a wildcard for subdomains, but eg. mywebsite.com will not work on HTTPS, only HTTP.

@barryvdh

FYI, when your bucket name contains dots, the HTTPS version does not work. The certificate is a wildcard for subdomains, but eg. mywebsite.com will not work on HTTPS, only HTTP.

That makes sense when using the https://bucket.with.a.dot.s3.amazonaws.com/ URL.

But it is possible to use custom domains with S3. What you have to do is name the bucket after the domain name. For example www.website.com.

In that case, https://www.website.com.s3.amazonaws.com/ will not work. But do you know if https://www.website.com will work correctly?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

t-geindre picture t-geindre  路  4Comments

f3l1x picture f3l1x  路  6Comments

akondas picture akondas  路  7Comments

spaceemotion picture spaceemotion  路  8Comments

mnapoli picture mnapoli  路  4Comments