0

I've setup a static website on S3 under a www.mydomain.com bucket. I also created a CNAME record for it in Namecheap looking like this:

  • Type: CNAME Record
  • Host: www
  • Value: www.mydomain.com.s3-website-ap-southeast1.amazonaws.com

It redirects correctly when I go to www.mydomain.com but the URL being displayed is of S3 and not my domain. If it helps, here's some output from dig:

;; ANSWER SECTION:
www.mydomain.com.    1177    IN      CNAME   www.mydomain.com.s3-website-ap-southeast-1.amazonaws.com.
www.mydomain.com.s3-website-ap-southeast-1.amazonaws.com. 60 IN CNAME s3-website-ap-southeast-1.amazonaws.com.
s3-website-ap-southeast-1.amazonaws.com. 5 IN A 54.231.242.137

When I checked the headers from curl, I got a 301.

Conrad
  • 1
  • 2
    It would probably help if you stopped censoring your domain name and S3 URLs. – ceejayoz Apr 06 '16 at 14:51
  • 1
    Doc say: _When you create a bucket, in any region, Amazon S3 updates DNS to reroute the request to the correct location, which might take time. In the meantime, the default rule applies and your virtual hosted–style request goes to the US East (N. Virginia) region, and Amazon S3 redirects it with HTTP 307 redirect to the correct region._ – Federico Sierra Apr 07 '16 at 01:38
  • @FedericoSierra that doesn't apply when the region-specific website or REST endpoints are used. It only applies to requests sent to hostnames in the format `bucket-name.s3.amazonaws.com`. – Michael - sqlbot Apr 07 '16 at 02:12
  • 1
    @Conrad you're definitely going to need to fill us in on your bucket name, as has already been mentioned. This is not the expected behavior, so it's essentially impossible for us to guess what you might have misconfigured or omitted from your question (such as whether you actually created 2 buckets, one without the www, which isn't going to work with namecheap). – Michael - sqlbot Apr 07 '16 at 02:17

2 Answers2

0

Figured it out - in have two buckets in S3 - mydomain.com and www.mydomain.com. mydomain.com is where the site is, and I set www.mydomain.com to redirect to mydomain.com.s3-website-ap-southeast1.amazonaws.com... I moved the files to www.mydomain.com and removed the redirect.

Conrad
  • 1
-3

Instead using a CNAME you can set an A record pointing directly to the HOST_IP_ADDRESS:

Type: A Record
Host: www.mydomain.com
Value: 54.231.242.137
Ra_
  • 677
  • 4
  • 9
  • 2
    Which is impossible with S3, as S3 doesn't have single or fixed IPs. S3 has millions of potential IPs, more than one at once, and they change regularly. – ceejayoz Apr 06 '16 at 14:16
  • Then, in order to avoid 301, the CNAME ServerName should be declared into webserver vhost config. Supposing apache: _ServerName www.mydomain.com.s3-website-ap-southeast1.amazonaws.com_ – Ra_ Apr 06 '16 at 14:42
  • Again impossible, as S3 is under Amazon's control, not yours. It's a hosted static file service. – ceejayoz Apr 06 '16 at 14:51