0

问题,nginx 缺少 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

我尝试过的:

1) 添加 application/woff2 woff2;/etc/nginx/mime.types(还有 application/x-font-woff2 等)

2)将此部分添加到服务器部分并且它可以工作

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

3)将上面的部分更改为此,仍然没有成功

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

我还查看nginx -T了配置以确保 woff2 没有其他条件。

4

1 回答 1

0

(3) 几乎是对的。还添加以下内容以删除上游的Content-Type

proxy_hide_header Content-Type;

mime.types在这种情况下,不需要更改文件。


但 Richard Smith 是对的,是上游返回了错误的内容类型。

于 2018-10-10T16:07:21.693 回答