Search code examples
amazon-web-servicesamazon-s3amazon-cloudfront

AWS CloudFront redirecting to S3 bucket


I have created a CloudFront distribution to serve the static website. S3 is origin server. Now if we access CloudFront URL, it redirects to S3 location.

d2s18t7gwlicql.cloudfront.net or test.telekha.in

In the browser it is showing https://telekha-test-www.s3.ap-south-1.amazonaws.com/index.html#/dashboard

I am expecting https://test.telekha.in/#/dashboard

If I access https://test.telekha.in through curl it returns my index.html document

If I access http://test.telekha.in through curl it returns

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>CloudFront</center>
</body>
</html>

But in browser both HTTP and HTTPS are redirecting to https://telekha-test-www.s3.ap-south-1.amazonaws.com/index.html#/

Please let me know how to resolve this issue.


Solution

  • I found the issue. It is with cloudfront configuration. This blog helped me.

    While defining the origin I have directly selected S3 bucket. We should enter the domain of the S3 bucket like telekha-test-www.s3-website.ap-south-1.amazonaws.com