Nginx cross domain configuration using font files

  • 2020-05-07 20:56:49
  • OfStack

Today, when using the subdomain to access the CSS of the root domain, it was found that the font could not be displayed. After ensuring that the path of CSS and Font fonts were loaded without problems, it was basically determined that the problem was cross-domain.

Add the allowed address of Access-Control-Allow-Origin via the Nginx module HttpHeadersModule.

solution

In the conf directory of Nginx, modify nginx.conf or domain conf corresponding to vhost, add the following code:


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

For a more detailed cross-domain configuration of Nginx, see the following article.

Wide-open CORS config for nginx


Related articles: