我已经设置了一个AWS S3存储桶以托管具有自己URL的静态网站。存储桶上的所有权限和其中的文件都是公共的。我通过打开index.html页面的公共链接来确认这一点。当我输入URL(ianpritchard.com)时,出现内部服务器错误。我将日志记录在存储桶中,并看到我的请求拒绝了访问。有谁知道为什么吗?我确实在托管区域中设置了A记录。
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>xxx</RequestId>
<HostId> xxxx </HostId>
</Error>
存储桶策略在这里-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::xxxx/"
}
]
}
答案 0 :(得分:0)
设置问题是您的IP指向公司IP而不是AWS。
AWS提供了一个干净的设置程序来托管域,
https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html
分4步。
开始之前
Step 1: Register a Domain
Step 2: Create and Configure Buckets and Upload Data
Step 3: Add Alias Records for example.com and www.example.com
Step 4: Testing
希望有帮助。
答案 1 :(得分:0)
您的策略看起来很奇怪,资源应为xxx/*
,委托人应为*
:
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"publicRead",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::xxxx/*"]
}
]
}
看到一些example here
不确定为什么/如何获得index.html
,发布index.html页面的公共链接: