0

I'm having trouble matching some file extensions in my Nginx config. I'm running nginx/1.11.6 on Debian x64.

I have this config: (located in server { } block)

location ~* \.(ttf|ttc|otf|eot|woff|woff2|css|js)$ {
    add_header Access-Control-Allow-Origin "*";
}

It should allow access to all these types of resources from any domain. But it doesn't work for woff and woff2.

I have tried this:

location ~* \.woff2$ {
    return 403;
}

But not even this does anything.

Result from CURL test looks like this:

curl -s -I -X GET https://cdn.xxxxx.xxx/font.woff2

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 21 Nov 2016 22:41:27 GMT
Content-Type: font/woff2
Content-Length: 14552
Last-Modified: Mon, 21 Nov 2016 22:31:42 GMT
Connection: keep-alive
ETag: "583375ce-38d8"
Expires: Wed, 21 Dec 2016 22:41:27 GMT
Cache-Control: max-age=2592000
Cache-Control: public
Accept-Ranges: bytes

Any idea where I might be wrong?

PSSGCSim
  • 1,247
  • 2
  • 18
  • 35
  • You are either editing the wrong `server` block, or there is a conflicting `location` or `rewrite` statement that is getting in first. – Richard Smith Nov 22 '16 at 08:07

1 Answers1

0

My problem was that expires.conf contained selector for woff and woff2 and this file was always included first. For some reason you can't match one file two times. Merging these two selectors solved the problem.

If there is better way to solve this please post an answer or comment. Thank you.

Got the idea where might be problem from @Richard Smith's comment.

PSSGCSim
  • 1,247
  • 2
  • 18
  • 35