Skip to content

Instantly share code, notes, and snippets.

@gaganawhad
Forked from atiw003/nginx-font-serving
Last active January 22, 2016 04:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gaganawhad/9651009 to your computer and use it in GitHub Desktop.
Save gaganawhad/9651009 to your computer and use it in GitHub Desktop.
Setting Accept-Control-Allow--Origin header on ( font ) assets in nginx. Helpful when using passenger on heroku

Currently passenger 4.0.39 and above come with a default nginx configuration file with a location @static_assets block. Paste the following inside it.

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

  if ($filename ~* ^.*?\.(eot)|(ttf)|(svg)|(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