You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rook-Ceph(RGW) S3网站根路径未重定向至index.html求助

解决Rook-Ceph RGW静态网站根路径不跳转index.html的问题

问题诊断

已完成RGW静态网站基础配置,单个页面可正常访问,但根路径返回对象列表而非跳转至index.html,这通常是RGW静态网站模式未在虚拟主机访问场景下正确生效,或配置未完全加载导致的。

排查与解决步骤

1. 重启RGW Pod加载最新配置

修改rook-config-override ConfigMap后,RGW Pod不会自动重载配置,需手动重启:

kubectl rollout restart deployment rook-ceph-rgw-example -n rook-ceph

等待Pod重启完成后,再次测试根路径访问。

2. 验证桶的静态网站配置是否生效

执行以下命令查看桶的网站配置详情:

aws --endpoint http://s3.example.org s3api get-bucket-website --bucket mybucket

预期返回应包含IndexDocument和ErrorDocument配置,示例:

{
    "IndexDocument": {
        "Suffix": "index.html"
    },
    "ErrorDocument": {
        "Key": "error.html"
    }
}

若返回为空或配置缺失,重新执行网站配置命令:

aws --endpoint http://s3.example.org s3 website s3://mybucket/ --index-document index.html --error-document error.html

3. 补充RGW虚拟主机模式配置

在rook-config-override ConfigMap的[client.rgw]段添加虚拟主机相关配置,确保RGW识别mybucket.example.org这类虚拟主机请求并触发静态网站逻辑:

apiVersion: v1
kind: ConfigMap
metadata:
  name: rook-config-override
  namespace: rook-ceph
data:
  config: |
    [global]
    osd_pool_default_size = 1
    rgw_enable_static_website = true
    rgw_enable_apis = s3, s3website
    
    [client.rgw]
    rgw_enable_static_website = true
    rgw_enable_apis = s3, s3website
    rgw_dns_name = s3.example.org
    rgw_vhost_style = true
    rgw_enable_dns_s3_style = false

更新ConfigMap后再次重启RGW Pod。

4. 检查桶的权限策略

确保桶的策略未允许匿名用户获取对象列表,同时授予静态网站访问所需权限。示例策略(替换mybucket为你的桶名):

aws --endpoint http://s3.example.org s3api put-bucket-policy --bucket mybucket --policy '{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::mybucket/*"
    }
  ]
}'

注意:策略中不要包含s3:ListBucket权限,否则根路径会优先返回对象列表而非触发网站跳转。

5. 直接测试RGW服务

跳过Ingress,直接访问RGW Pod的服务地址验证:

curl -H "Host: mybucket.example.org" http://<rook-ceph-rgw-example-service-ip>:80

若此时能正确跳转至index.html,说明问题出在Ingress配置;若仍返回对象列表,则聚焦RGW自身配置调整。

内容的提问来源于stack exchange,提问作者cybercoder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 00:03:32