<p>The &quot;nginx.ingress.kubernetes.io/rewrite-target&quot; annotation on my ingress resource does not seem to be doing anything. Everything works just fine when I change <code>path: /helloworld</code> to <code>path: /</code>. I have tried putting the annotation's value in double quotes and changing the order of annotations to no effect. What am I missing? It seems like this should be fairly straightforward.</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: helloworld-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: &lt;NGINX_CONTROLLER_EXTERNAL_IP&gt;.xip.io
    http:
      paths:
      - backend:
          serviceName: helloworld-svc
          servicePort: 80
        path: /helloworld
</code></pre>

2um9YJ6haZ7wKP4m
<p>I solved my problem. It was not related to the &quot;rewrite-target&quot; annotation itself. I was trying to point it to a Nginx server serving a React.js app. I needed to set the base URL within the React app and copy the build to the corresponding subdirectory of <code>/usr/share/nginx/html</code> in the Dockerfile. After taking those steps there was no need for using &quot;rewrite-target&quot; anymore. I posted a <a href="https://stackoverflow.com/questions/65546735/rewrite-target-failing-when-routing-to-react-js-app-on-nginx-server/65560923#65560923">separate question</a> detailing the setup with React and Nginx and answered it too.</p>
