# 对象存储原始域名添加响应头

针对对象存储的原始域名无法添加指定的响应头的问题,

  1. 通过cdn解决,在cdn的域名上添加指定的响应头
  2. 通过nginx代理解决。(会占用服务器的带宽)

nginx配置文件参考

server {
	listen 15050 default_server;
	listen [::]:15050 default_server;
	
	ssl on;
	ssl_certificate /etc/nginx/cert/Nginx/testeditor.meishesdk.com.crt;
	ssl_certificate_key /etc/nginx/cert/Nginx/testeditor.meishesdk.com.key;
	ssl_session_timeout 5m;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;

	location /resource/ {
    proxy_pass https://bseditor.oss-cn-beijing.aliyuncs.com/;
    proxy_set_header Host $proxy_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Via "nginx";
  }

  add_header Cross-Origin-Resource-Policy cross-origin;
}

[

](https://alieasset.meishesdk.com/test/resource/image/2021/07/22/15293/2428d868-3fe5-4e45-b912-6c603f7e5040.jpg) 原始地址的响应头 https://bseditor.oss-cn-beijing.aliyuncs.com/test/resource/image/2021/07/22/15293/2428d868-3fe5-4e45-b912-6c603f7e5040.jpg (opens new window) image.png

代理之后的响应头 https://testeditor.meishesdk.com/resource/test/resource/image/2021/07/22/15293/2428d868-3fe5-4e45-b912-6c603f7e5040.jpg (opens new window)

image.png