ceph跨域问题

解决Ceph跨域问题

https://help.dreamhost.com/hc/en-us/articles/216201557-How-to-setup-Cross-Origin-Resource-Sharing-CORS-on-DreamObjects

现象:

edu.valsun.cn 里js访问ceph对象存储 http://ceph.valsun.cn/EDU/p/course/20180313/1-0f1e2da9cbf438d03c2dba050220ff77.m3u8

报如下错误

1
Failed to load  http://ceph.valsun.cn/EDU/p/course/20180313/1-0f1e2da9cbf438d03c2dba050220ff77.m3u8: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://edu.valsun.cn' is therefore not allowed access.

修改ceph.conf配置文件

1
2
3
cd my-cluster/
vim ceph.conf
rgw_dns_name = ceph.valsun.cn

覆盖各个节点配置

1
ceph-deploy --overwrite-conf config push openstack-nova29 openstack-nova30 

在各自节点重启rgw服务

1
2
3
systemctl restart ceph-radosgw@rgw.openstack-nova28.service
systemctl restart ceph-radosgw@rgw.openstack-nova29.service
systemctl restart ceph-radosgw@rgw.openstack-nova30.service

给s3存储桶设置CORS规则

写 CORS 规则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@openstack-nova28 ~]# cat rules.xml 
<CORSConfiguration>
<CORSRule>
<ID>Allow
everything</ID>
<AllowedOrigin>http://edu.valsun.cn</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<MaxAgeSeconds>30</MaxAgeSeconds>
</CORSRule>
</CORSConfiguration>

给对应的存储桶设置cors规则

1
2
s3cmd setcors rules.xml s3://EDU
s3cmd info s3://EDU #查看规则

我的nginx转发代理配置

server_name 填写和rgw_dns_name 一致
m7WmwT.png

再次访问,问题解决