Amazon S3 下载index.html 而不是提供服务

2024-02-08

我已设置 Amazon S3 来为我的静态站点提供服务,speakeasylinguistics.com。所有 DNS 东西似乎都工作正常,因为dig +recurse +trace www.speakeasylinguistics.com输出正确的 DNS 信息。

但是当你在浏览器中访问该网站 http://speakeasylinguistics.com.s3-website-us-east-1.amazonaws.com使用端点,index.html页面下载,而不是提供服务。我该如何解决?

我试过 Chrome、Safari、FF。这发生在他们所有人身上。我用了亚马逊的攻略 http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html将自定义域托管到 T.


如果您正在使用Hashicorp 地形 https://www.terraform.io/你可以指定content-type on an aws_s3_bucket_object https://www.terraform.io/docs/providers/aws/r/s3_bucket_object.html如下

resource "aws_s3_bucket_object" "index" {
  bucket = "yourbucketnamehere"
  key = "index.html"
  content = "<h1>Hello, world</h1>"

  content_type = "text/html"
}

这应该在浏览器中适当地提供您的内容。

22 年 5 月 24 日编辑:正如此答案的评论中提到的,Terraform现在有一个模块 https://registry.terraform.io/modules/hashicorp/dir/template/latest帮助上传文件并设置它们content-type属性正确

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Amazon S3 下载index.html 而不是提供服务 的相关文章

随机推荐