<p>I have the following configuration for rewrite for user-service and it is supposed to remove either 'sso' or 'user' and use the rest of the path to redirect to the user-service</p>
<p>nginx-ingress-controller:0.32.0</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: user-service
  namespace: pre-prod
  annotations:
    cert-manager.io/cluster-issuer: clusterissuer-selfsigned-default
    ingress.kubernetes.io/rewrite-target: /$2/$4
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/force-ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/enable-cors: &quot;true&quot;
    nginx.ingress.kubernetes.io/cors-allow-origin: &quot;https://example.com&quot;
  labels:
    app: pre-prod
    component: user-service
spec:
  rules:
    - host: example.com
      http:
        paths:
          - path: /(user|sso)/(api|saml)(/|$)(.*)
            backend:
              serviceName: user-service
              servicePort: 80
</code></pre>
<p>The path /sso/api/auth/sso/signin is supposed to be converted into /api/auth/sso/signin but the backend sends the response</p>
<pre><code>error: &quot;Not Found&quot;
message: &quot;No message available&quot;
path: &quot;/sso/api/auth/sso/signin&quot;
status: 404
timestamp: &quot;2021-01-20T09:47:04.544+0000&quot;
</code></pre>
<p><code>172.18.240.0 - - [20/Jan/2021:09:47:04 +0000] &quot;GET /sso/api/auth/sso/signin HTTP/1.1&quot; 404 161 &quot;https://example.com/login&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36&quot; 693 0.023 [pre-prod-user-service-80] [] 172.18.64.24:9090 166 0.022 404 a5844078b332b882056516aa50b0eb2b</code></p>
<p>What could be the problem?</p>
<p>Thanks</p>

Andrey Yaroshenko
<p>The annotation has a typo, in that it omitted the leading <code>nginx.</code> from <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rewrite" rel="nofollow noreferrer"><code>nginx.ingress.kubernetes.io/rewrite-target:</code></a></p>
