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
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With