0

The problem, nginx missing content type for woff2

curl -s -I -X GET https://.../Montserrat-Medium.woff2
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 10 Oct 2018 10:30:54 GMT
Content-Length: 118676
Connection: keep-alive
Keep-Alive: timeout=60
Last-Modified: Wed, 10 Oct 2018 10:27:24 GMT
ETag: "1cf94-577dd4cdf1e25"
Accept-Ranges: bytes

What I've try:

  1. added application/woff2 woff2; to /etc/nginx/mime.types (also application/x-font-woff2, etc)

  2. add to server section this part and it works

    location ~* ^.+.woff2$ { return 403; }

  3. change part above to this and still have no success

    location ~* ^.+\.woff2$ {
        proxy_pass      https://82.202.226.111:8443;
        add_header      Content-type application/woff2;
        root            /var/web/public_shtml;
        access_log      off;
        expires         7d;
        try_files       $uri @fallback;
    }

Also I've view nginx -T configuration to be sure where is no other conditions for woff2.

SiZE
  • 2,217
  • 1
  • 13
  • 24

1 Answers1

0

(3) is almost right. Add also the following to remove the upstream's Content-Type:

proxy_hide_header Content-Type;

Changes to mime.types file are not necessary in this case.


But Richard Smith is right, it's the upstream who returns the wrong content type.

Alexander Azarov
  • 12,971
  • 2
  • 50
  • 54