<p>I'm setting up my Kubernetes Cluster using Azure AKS and I deployed NGINX Ingress following this guide:
<a href="https://learn.microsoft.com/en-us/azure/aks/ingress-internal-ip" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/aks/ingress-internal-ip</a></p>
<p>Now the guide works great for the demo applications it demonstrates on but when I tried deploying one of my own apps the page only showed the html parts and for the js, css and png parts I got the following errors in the Console:
<a href="https://i.stack.imgur.com/UxZcd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UxZcd.png" alt="enter image description here" /></a></p>
<p>When I deploy the application without NGINX Ingress on my K8S cluster it works perfectly but for some reason when I deploy it through NGINX I get these errors.</p>
<p>I also tried deploying another app, pgAdmin, and for that I only receive an error 503 when I try to approach its' page.</p>
<p>I tried several workarounds I found on the web but nothing seemed to fix it.</p>
<p><strong>Files:</strong></p>
<p>internal-ingress.yaml:</p>
<pre><code>controller:
service:
  loadBalancerIP: 10.50.0.253
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-internal: &quot;true&quot;
</code></pre>
<p>hello-world-ingress.yaml:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: hello-world-ingress
  namespace: infra
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
   - http:
      paths:
      - backend:
          serviceName: aks-helloworld
          servicePort: 80
        path: /hello-world-one(/|$)(.*)  
      - backend:
          serviceName: pgadmin
          servicePort: 80
        path: /pgadmin(/|$)(.*)
      - backend:
          serviceName: pgadmin
          servicePort: 80
        path: /(.*)
      - backend:
           serviceName: box-model
           servicePort: 80
        path: /box-model(/|$)(.*)
</code></pre>
<p>pgadmin deployment yaml:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.pgadmin.name }}
spec:
  selector:
    matchLabels:
      app: {{.Values.pgadmin.name}}
  replicas: {{.Values.pgadmin.deployment.replicas}}
  strategy:
    type: {{.Values.pgadmin.deployment.strategy}}
  template:
    metadata:
      labels:
        app: {{.Values.pgadmin.name}}
    spec:
      containers:
      - env:
        - name: PGADMIN_DEFAULT_EMAIL
          valueFrom: 
            secretKeyRef:  
              name: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_EMAIL.name}}
              key: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_EMAIL.key}}
        - name: PGADMIN_DEFAULT_PASSWORD
          valueFrom: 
            secretKeyRef:  
              name: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_PASSWORD.name}} 
              key: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_PASSWORD.key}}
        image: {{.Values.pgadmin.deployment.image}}
        imagePullPolicy: {{.Values.pgadmin.deployment.imagePullPolicy}}
        name: {{.Values.pgadmin.name}}
        ports:
        - containerPort: {{.Values.pgadmin.deployment.containerPort}}
        volumeMounts: 
        - mountPath: {{.Values.pgadmin.deployment.volumeMounts.name}}
          name: {{.Values.pgadmin.deployment.volumeMounts.name}}
        resources: {}
      restartPolicy: {{.Values.pgadmin.deployment.restartPolicy}}
      serviceAccountName: &quot;&quot;
      volumes:
        - name: {{.Values.pgadmin.volumes.pvc.name}}
          persistentVolumeClaim:
            claimName: {{.Values.pgadmin.volumes.pvc.name}}
status: {}
</code></pre>
<p>pgadmin service yaml:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: {{.Values.pgadmin.name}}
spec:
  ports:
  - name: {{.Values.pgadmin.deployment.containerPort | quote}} 
    port: {{.Values.pgadmin.deployment.containerPort}}
    targetPort: {{.Values.pgadmin.deployment.containerPort}}
status:
  loadBalancer: {}
</code></pre>
<p>Please tell me if a relevant information is missing and I will add it.</p>

teamdever
<p>May be nginx.ingress.kubernetes.io/rewrite-target: /$1 is creating an issue. I am not sure.</p>
