<p>I have a Kubernetes cluster that is making use of an Ingress to forward on traffic to a frontend React app and a backend Flask app. My problem is that the React app only works if rewrite-target annotation is not set and the flask app only works if it is.</p>
<p>How can I get my flask app accessible without setting this value (commented out in below yaml).</p>
<p>Here is the Ingress controller:</p>
<pre><code>metadata:
  name: thesis-ingress
  namespace: thesis
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/add-base-url: &quot;true&quot;
#    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/service-upstream: &quot;true&quot;
spec:
  tls:
    - hosts:
        - thesis
      secretName: ingress-tls
  rules:
    - host: thesis.info
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: frontend
              port:
                number: 3000
        - path: /backend
          pathType: Prefix
          backend:
            service:
              name: backend
              port:
                number: 5000
</code></pre>

EoinHanan
<p>Your question didn't specify, but I'm guessing your capture group was to rewrite <code>/backend/(.+)</code> to <code>/$1</code>; on that assumption:</p>
<p>Be aware that annotations are per-Ingress, but all Ingress resources are unioned across the cluster to comprise the whole of the configuration. Thus, if you need one rewrite and one without, just create two Ingress resources</p>
<pre class="lang-yaml prettyprint-override"><code>metadata:
  name: thesis-frontend
  namespace: thesis
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/add-base-url: &quot;true&quot;
    nginx.ingress.kubernetes.io/service-upstream: &quot;true&quot;
spec:
  tls:
    - hosts:
        - thesis
      secretName: ingress-tls
  rules:
    - host: thesis.info
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: frontend
              port:
                number: 3000
---
metadata:
  name: thesis-backend
  namespace: thesis
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/add-base-url: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/service-upstream: &quot;true&quot;
spec:
  tls:
    - hosts:
        - thesis
      secretName: ingress-tls
  rules:
    - host: thesis.info
        - path: /backend/(.+)
          backend:
            service:
              name: backend
              port:
                number: 5000
</code></pre>
