Add Access Control Allow Origin Region(CORS) for fonts in NGINX?

Date Posted: 02-10-2017

In this post, we will explain on how to allow cors (Cross Origin Region) for fonts on nginx. We may have seen the following on google chrome console or firefox firebug addon.

No ‘Access-Control-Allow-Origin’ header is


  1. Nginx Webserver.  If nginx is not installed, follow the posts.
    1. Ubuntu 16.04
    2. Centos 7


If you followed the above posts, the default location of nginx configuration is /etc/nginx/sites-enabled/default.

Open nginx configuration and add the following lines inside location / section

vi /etc/nginx/sites-enabled/default

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

The above code will allow access control region when the request is GET.

Verify the nginx syntax.

nginx -t

Restart the nginx service

systemctl restart nginx


Leave a Reply