Nginx-ingress-controller cannot load static assets for application

39 views Asked by At

I have deployed an AWS EKS cluster and then an nginx-ingress-controller.

I then tried to deploy ArgoCD on the cluster. The ingress seems to be working fine, the requests to my loadbalancer DNS hostname returns 200 when I try myloadbalancerDNS.com/argo

BUT none of the static assets are being loaded, something is wrong with my route/pathing rules.

Here is my ingress

    alb.ingress.kubernetes.io/ssl-passthrough: "true"
    kubernetes.io/ingress.class: nginx
    meta.helm.sh/release-name: argocd
    meta.helm.sh/release-namespace: argo
    nginx.ingress.kubernetes.io/backend-protocol: HTTP
    nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: "true"
  creationTimestamp: "2024-02-27T17:22:38Z"
  generation: 7
  labels:
    app.kubernetes.io/component: server
    app.kubernetes.io/instance: argocd
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: argocd-server
    app.kubernetes.io/part-of: argocd
    app.kubernetes.io/version: v2.10.1
    helm.sh/chart: argo-cd-6.2.3
  name: argocd-server
  namespace: argo
  resourceVersion: "302643"
  uid: 09919fd3-d032-4dba-9fa7-0e693e797357
spec:
  ingressClassName: nginx
  rules:
  - host: a3d5ec6525a3642b1a50bc17d3e46b34-221545762.eu-west-1.elb.amazonaws.com
    http:
      paths:
      - backend:
          service:
            name: argocd-server
            port:
              number: 443
        path: /argo/?(.*)
        pathType: Exact

Note when I run curl a3d5ec6525a3642b1a50bc17d3e46b34-221545762.eu-west-1.elb.amazonaws.com/argo/assets/fonts.css it works, but when I visit the page on the browser a3d5ec6525a3642b1a50bc17d3e46b34-221545762.eu-west-1.elb.amazonaws.com/argo, it returns 404 errors for all static assets

So TL;DR

When i visit myLoadBalancer.com/argo, I'm expecting my nginx-ingress-controller to load assets from myLoadBalancer.com/argo/assets/etc, but instead it's look for myLoadBalancer.com/assets directly

1

There are 1 answers

0
iamwillbin On

The path: /argo/?(.\*) in your ingress rules is not matching the path of your static assets, which is /argo/assets/.

You should modify your ingress rules to match the correct path for your static assets. Update the path in your ingress rules to /argo/assets/?(.\*).

      path: /argo/assets/?(.*)
      pathType: Exact

The nginx-ingress-controller should correctly route requests to your static assets, and you should no longer encounter 404 errors.