I serve static files through an nginx instance there's also another nginx instance acting as an ingress controller. It's provided by my cloud provider.
Sometimes when I hit the page the network tab in the page inspector (in google chrome: ctrl+maj+i
) mentions 502 error on some static files.
f5
the errors disappearctrl + f5
, some errors reappear (not always the same files), until I press f5
gainkubectl logs ingress_pod_name -n kube-system
), I see two cases: 1. multiples lines of 502 connect() failed (111: Connection refused) while connecting to upstream
, then 200 at some point, 2. multiple lines of 502 and that's itf5
or ctrl + f5
does not change that. But, the ingress logs shows 502 errors and ctrl + f5
shows me a "favicon.ico" 404 not found in the inspector's network tab, I don't think it's relevant but it's weird that it appears whenever there's a 502My service and ingress :
apiVersion: v1
kind: Service
metadata:
name: myapp-service
labels:
app: myapp
spec:
type: ClusterIP
selector:
app: myapp
ports:
- name: myapp-backend
port: 9000
targetPort: 9000
- name: myapp-frontend
port: 8080
targetPort: 8080
- name: myapp-nginx
port: 8001
targetPort: 8001
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myapp-ingress
labels:
app: myapp
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
spec:
rules:
- host: myapp.example.cloud
http:
paths:
- pathType: Prefix
path: /core
backend:
service:
name: myapp-service
port:
number: 9000
- pathType: Prefix
path: "/core_media|core_static/"
backend:
service:
name: myapp-service
port:
number: 8001
- pathType: Prefix
path: "/"
backend:
service:
name: myapp-service
port:
number: 8080