Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to use cloudfront as a CDN to speed up a site. I've got all the JS & CSS working fine but I'm stuck on some webfonts which won't load from the CDN.

I've setup Apache VHOSTS file with the Access-Control-Allow-Origin using the following syntax:

Header always set Access-Control-Allow-Origin "*.example.com"

Have I put in the correct domain for the Access-Control-Allow-Origin or should it be http://www.example.com? In this case http://cdn.example.com is the CNAME point to the cloudfront DNS.

When I curl I get headings like this:

HTTP/1.0 200 OK
Content-Length: 41012
Connection: keep-alive
Date: Sun, 09 Jun 2013 20:59:30 GMT
Server: Apache/2.2.22 (Ubuntu)
Last-Modified: Fri, 04 May 2012 12:36:06 GMT
Accept-Ranges: bytes
Access-Control-Allow-Origin: *.example.com
Age: 1805
Via: 1.0 cbe4bca697a4e3585803757de75edba7.cloudfront.net (CloudFront)
X-Cache: Hit from cloudfront
X-Amz-Cf-Id: 2im15Ds6Vk81kxdZKtPh7w0JUjW9qyPMgFbnXzrN_RfxJCkeyOjEbg==

But when I look at the same file in Firebug I don't see the Access-Control-Allow-Origin header.

The fonts are called in a stylesheet in this manner

@font-face {
 font-family: 'TitilliumRegular';
 src: url('TitilliumText1.eot');
 src: local('Titillium Regular'), local('Titillium-Bold'), url('TitilliumText1.ttf') format('truetype');
}

This stylesheet is then imported into another using @import url("../fonts/titillium/stylesheet.css");

I've read various posts on the CORS and cloudfront and as far as I can tell, the settings are correct. What am I missing?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

So to fix above problem required two things:

  1. Converted Access-Control-Allow-Origin from the domain to *
  2. Created a new CloudFront distribution as it was nearly impossible to invalidate the fonts within the cache

Once this was done, it all worked fine.

share|improve this answer
    
After multiple invalidation attempts, recreating the CF distribution was the only thing that worked for me as well. Weird, in another case invalidations worked fine and the new headers were picked up correctly... –  Manuel Meurer Oct 19 '13 at 14:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.