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:
But when running on Kubernetes. Content type always is text/html:
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
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;
}
}
Try adding anotation :
are you using nginx ingress ?
nginx.ingress.kubernetes.io/rewrite-target: /