Skip to content

Instantly share code, notes, and snippets.

@atiw003
Forked from sideshowcoder/nginx-font-serving
Created August 8, 2011 14:57
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save atiw003/1131897 to your computer and use it in GitHub Desktop.
Save atiw003/1131897 to your computer and use it in GitHub Desktop.
Nginx header write for serving fonts to firefox cross domain
For nginx,
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
Or better way inside virtual host location use,
Inside location use
if ($request_filename ~* ^.?/([^/]?)$)
{
set $filename $1;
}
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
add_header Access-Control-Allow-Origin *;
}
For Apache
For apache in apache.conf
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
@atiw003
Copy link
Author

atiw003 commented Aug 8, 2011

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment