Nginx Kubernetes Ingress does not serve .ttf or .woff files

1/1/2020

My Nginx Kubernetes ingress I think is not properly configured to serve .ttf file.

On safari work properly, but on chrome I have an error about cors allow. I checked my .conf Nginx file on my deployed ingress and "more_set_headers Access-Control-Allow-Origin: * is configured.

I think I need to add some annotations on mime.types or gzip config.

    apiVersion: networking.k8s.io/v1beta1
    kind: Ingress
    metadata:
      name: cc-i
      annotations:
        nginx.ingress.kubernetes.io/enable-cors: "true"
    spec:
      rules:
      - host: myapp.com
        http:
          paths:
          - backend:
              serviceName: cc-s
              servicePort: 80
      - http:
          paths:
          - backend:
              serviceName: cc-s
              servicePort: 80
-- cuscode
annotations
kubernetes
mime-types
nginx
nginx-ingress

2 Answers

1/1/2020

Verify wich type of installation you have made and verify you have the nginx-config configmap. See docs

If you don't have, create one and set this in the data area:

data:
  gzip_types: application/x-font-ttf application/font-woff

And if you need more gzip_type you could add too. Here are the default values.

If the problem is the gzip config like you say this will solve your problem.

-- Jhonn Frazão
Source: StackOverflow

1/2/2020

Some CDN services has a cors configuration that need to be configured. In my case i added a cors authorized domain on my digitalocean space. This solved on firefox and chrome.

-- cuscode
Source: StackOverflow