nginx + @font-face + Firefox / IE9

Posted by Philip Seyfi on Server Fault See other posts from Server Fault or by Philip Seyfi
Published on 2011-11-16T23:47:17Z Indexed on 2011/11/17 1:53 UTC
Read the original article Hit count: 493

Filed under:
|

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' '*'; 
    } 
}

With all of the following combinations:

add_header Access-Control-Allow-Origin *;

add_header 'Access-Control-Allow-Origin' *;

add_header Access-Control-Allow-Origin '*';

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?

© Server Fault or respective owner

Related posts about nginx

Related posts about http-headers