I have created an EKS using AWS ALB Ingress Controller and also created a ingress for the same. But after creating the ingress, I am getting 404 while accessing some file extension. Ex: main.css. Following is my ingress code.
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: instance
kubernetes.io/ingress.class: alb
name: my-site
namespace: my-site
spec:
rules:
-
host: my-site.com
http:
paths:
-
backend:
service:
name: my-site-front-end-service
port:
number: 80
path: /
pathType: Exact
-
backend:
service:
name: my-site-backend-service
port:
number: 3000
path: /marketing/
pathType: Prefix
My frontend application needs to be available on HTTP://my-site.com
and the backend service in the URL HTTP://my-site.com/marketing/
.But now I am getting 404 for some of the .css files. The URL for the files are like, HTTP://my-site.com/main.css , HTTP://my-site.com//main-5a17625f9c68d9c60c4c.js . What is wrong with my ingress configuration?
When I update the path type to prefix in the frotend-service section, all the calls will be forwarded to frontend hence the calls to the backend service don't work.
Your ingress endpoint /
is of type ExactMatch
. Therefore, the files matching /*
will not be matched . You can change this to type Prefix
and it should work.
Additionally, consider moving your files away from the root of the path to somewhere like /files/
and then use /files
as a prefix
type ingress route. This will make sure the /
path remains exactmatch
so as not to confuse it with other paths.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.