`

aws cdn字体跨域问题

    博客分类:
  • aws
阅读更多
1: 首先设置nginx服务器支持跨域,如下

    if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain; charset=utf-8';
        add_header 'Content-Length' 0;
        return 204;
     }
     if ($request_method = 'GET') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
        add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
     }


2:打开aws的cdn,选择源,进行编辑,在底部 "源自定义标头标头名称"添加如下内容:

Access-Control-Allow-Methods  GET
Access-Control-Allow-Origin *


3: 选择行为,编辑

1)"允许的 HTTP 方法"  "GET、HEAD、OPTIONS"
2) "缓存的 HTTP 方法"  "OPTIONS"
3) "基于选择的请求标头进行缓存白"  白名单
4)"白名单标头"  Origin



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics