Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx - WebFont CORS rule never matched #85

Closed
mdoelker opened this issue Aug 13, 2012 · 0 comments
Closed

nginx - WebFont CORS rule never matched #85

mdoelker opened this issue Aug 13, 2012 · 0 comments

Comments

@mdoelker
Copy link

In the current version of the nginx site config (2012-07-23 that is) following snippet

  # Cross domain webfont access
  location ~* \.(ttf|ttc|otf|eot|woff|font.css)$ {
      add_header "Access-Control-Allow-Origin" "*";
  }

is always outmatched by preceeding

  # Media: images, video, audio, HTC, WebFonts
  location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
    expires 1M;
    access_log off;
    add_header Cache-Control "public";
  }

Unfortunately it's not possible to have multiple locations match as the docs say:
"The first regular expression to match the query will stop the search."

A possible fix would be to remove webfonts extensions from the media block and change the webfont block to

  # Cross domain webfont access
  location ~* \.(ttf|ttc|otf|eot|woff)$ {
    add_header Access-Control-Allow-Origin "http://www.clans.de";
    expires 1M;
    access_log off;
    add_header Cache-Control "public";
  }
@AD7six AD7six closed this as completed in 15a669a Aug 19, 2012
alrra pushed a commit to h5bp/server-configs-nginx that referenced this issue Jul 28, 2013
Only one location match is ever executed - therefore the relevant
location match must contain all relevant rules.

cross-domain-fonts is included by default, therefore for right now add
the cache rules for these requests directly to the
cross-domain-fonts.conf file

fixes h5bp/server-configs#85
fixes h5bp/server-configs#86

Thanks to @misterjack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants