How can I make nginx support @font-face formats and allow access-control-allow-origin?
Woot! Got it.. It was pretty much what I suspected in my edit, I had to basically do the regex filename check in my sole location {}
instead of making an alternative one.
location / {
root /www/site.org/public/;
index index.html;
if ($request_filename ~* ^.*?/([^/]*?)$)
{
set $filename $1;
}
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
add_header Access-Control-Allow-Origin *;
}
}
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
If you have other font extensions, pay close attention to add them as well. Nowdays it common to have: eot|ttf|woff|woff2|svg, so you should adjust like so:
location ~* \.(eot|ttf|woff|woff2|svg)$ {
add_header Access-Control-Allow-Origin *;
}