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.

Just transferred my site from a shared hosting to Linode's VPS, and I'm also completely new to nginx, so please don't be harsh if I missed something evident ^^

I've got my WordPress site running pretty well on nginx & MaxCDN, but my @font-face fonts (served from cdn.domain.com) stopped working in IE9 and FF (@font-face failed cross-origin request. Resource access is restricted.)

I've googled for hours and tried adding all of the following to my config files:

location ~* ^.+\.(eot|otf|ttf|woff)$ { 
    add_header Access-Control-Allow-Origin *; 
}


location ^/fonts/ { 
    add_header Access-Control-Allow-Origin *; 
}


location / { 
    if ($request_filename ~* ^.*?/([^/]*?)$) 
    { 
        set $filename $1; 
    } 

    if ($filename ~* ^.*?\.(eot)|(otf)|(ttf)|(woff)$){ 
        add_header 'Access-Control-Allow-Origin' '*'; 
    } 
}

Of course, I've restarted nginx after every change.

The headers just don't get sent at all no matter what I do.

I have the default Ubuntu apt-get build nginx which should include the headers module by default... How do I check what modules are installed, or what else could be causing this error?

UPDATE:

I've tried running curl -I [location-of-the-font] and it does return Access-Control-Allow-Origin: * but the header is not visible in Chrome's Network panel and the fonts still don't work in FF & IE9 (CSS3117: @font-face failed cross-origin request. Resource access is restricted.) - Any ideas what could be causing this?

share|improve this question
2  
Very poorly described issue. Unclear are you checking with Chrome using CDN or direct URL from your server. You could give us exact URLs and detailed information on what you're doing, what you're expecting and where it's failing to conform to your expectations. –  poige Jun 27 at 14:17
    
clear the cache? not use @font-face? –  cnst Jun 30 at 3:54

1 Answer 1

The only suggestion that could be given is that you must, (1), ensure you clear the cache within your browser, and, (2), ensure that add_header is present at the appropriate level.

There's not much point in defining it everywhere. If all your fonts are served from within location /fonts, then that's the only location where you must declare the appropriate add_header, and you must also ensure that no further sub-locations have any other add_header directives, either, because that would reset all prior add_header directions at the preceding levels.

share|improve this answer

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.