Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes Ingress deploy Angular assets (image) doesn't show

I use Docker to package the Angular project (container use Nginx). When running on Docker, the images shows up ok, but when deploying to Kubernetes, using Ingress, all images in the assets folder do not appear.

Content-Type running on Docker. It's OK:

Link Image

But when running on Kubernetes. Content type always is text/html:

Link Image

Config Ingress Kubernetes. Service name ssite.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: abc-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "swing-static-ip"
    ingress.kubernetes.io/force-ssl-redirect: "true"
    ingress.gcp.kubernetes.io/pre-shared-cert: "abc,xyz"
spec:
  rules:
  - host: abc.com
    http:
      paths:
      - backend:
          serviceName: sservice
          servicePort: 8000
  - host: xyz.com
    http:
      paths:
      - path : /
        backend:
          serviceName: ssite
          servicePort: 80
      - path : /*
        backend:
          serviceName: ssite
          servicePort: 80
like image 597
NguyenHung Avatar asked May 31 '26 01:05

NguyenHung


1 Answers

In your nginx config set default_type directive

Defines the default MIME type of a response. Mapping of file name extensions to MIME types can be set with the types directive.

server {
   ...
   default_type text/html;

   location /assets/imgs {
      default_type image/png;
   }

   location /assets/imgs {
      default_type image/jpeg;
   }
}
like image 119
A_Suh Avatar answered Jun 02 '26 19:06

A_Suh