title: nginx-ingress rewrite-target to /api not working
body: <p>i am trying to get api as location (/api) to work with intress settings</p>
  <p>this is my ingress:</p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: ingress-dev
    annotations:
      # use the shared ingress-nginx
      kubernetes.io/ingress.class: &quot;nginx&quot;
      #nginx.ingress.kubernetes.io/rewrite-target: /
      #nginx.ingress.kubernetes.io/app-root: /
      
  spec:
    rules:
    - host: 'dev.example.com'
      http:
        paths:
        - path: /api
          pathType: Prefix
          backend:
            service:
              name: my-ruby
              port: 3000
  
  </code></pre>
  <p>when i curl dev.example.com/api/check_version
  i get error</p>
  <pre><code>I, [2021-12-01T16:43:35.776502 #13]  INFO -- : [7253cca0b88503d625af527db32eb92e] Started GET &quot;/api/check_serverr&quot; for 10.42.1.228 at 2021-12-01 16:43:35 +0300
  F, [2021-12-01T16:43:35.779603 #13] FATAL -- : [7253cca0b88503d625af527db32eb92e]
  [7253cca0b88503d625af527db32eb92e] ActionController::RoutingError (No route matches [GET] &quot;/api/check_version&quot;):
  </code></pre>
  <p>if i add annotation nginx.ingress.kubernetes.io/rewrite-target: /</p>
  <p>get error</p>
  <pre><code>I, [2021-12-01T16:49:11.153280 #13]  INFO -- : [7832de5c07e3a173ddc86ebab5735cec] Started GET &quot;/&quot; for 10.42.1.228 at 2021-12-01 16:49:11 +0300
  F, [2021-12-01T16:49:11.154435 #13] FATAL -- : [7832de5c07e3a173ddc86ebab5735cec]
  [7832de5c07e3a173ddc86ebab5735cec] ActionController::RoutingError (No route matches [GET] &quot;/&quot;):
  </code></pre>
  <p>how to make a rewrite correctly in this case?</p>