<p>This question is similar to the <a href="https://stackoverflow.com/questions/57764237/kubernetes-ingress-to-external-service">question</a> but this is more around the path in the rule that can be configured.</p>

<p>The ingress should be able to handle both the internal services and an external service. The Url for the external service should be something like <a href="http://host_name:80/es" rel="nofollow noreferrer">http://host_name:80/es</a>. When the user hits this url, this should be redirected to the external service.</p>

<p>The service definition and the ingress rule are configured as below but it leads to 404.
Where am i going wrong?</p>

<p><strong>Ingress rules</strong></p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: external-service
  annotations:
    kubernetes.io/ingress.class: “nginx”
    nginx.ingress.kubernetes.io/ingress.class: “nginx”
    nginx.ingress.kubernetes.io/ssl-redirect: “false”
spec:
  rules:
  - host:
    http:
      paths:
      - backend:
          serviceName: external-ip
          servicePort: 80
        path: /es
</code></pre>

<p><strong>Service and End Point definitions</strong></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: external-ip
spec:
  ports:
  - name: app
    port: 80
    protocol: TCP
    targetPort: 80
---
apiVersion: v1
kind: Endpoints
metadata:
  name: external-ip
subsets:
- addresses:
  - ip: &lt;ip to external service&gt;
  ports:
  - name: app
    port: 80
    protocol: TCP
</code></pre>

<p>It works when i try with the URL <a href="http://host_name:80" rel="nofollow noreferrer">http://host_name:80</a> and the following ingress rule. Please note the difference in the path in the ingress rule.</p>

<pre><code>apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: external-service
      annotations:
        kubernetes.io/ingress.class: “nginx”
        nginx.ingress.kubernetes.io/ingress.class: “nginx”
        nginx.ingress.kubernetes.io/ssl-redirect: “false”
    spec:
      rules:
      - host:
        http:
          paths:
          - backend:
              serviceName: external-ip
              servicePort: 80
            path: /
</code></pre>

<p>There is a service that can echo my request back to me: <a href="https://postman-echo.com/" rel="nofollow noreferrer">https://postman-echo.com/</a>, it will come useful later.
Here is its ip and it will simulate your external service:</p>

<pre><code>$ dig postman-echo.com +short
107.23.20.188
</code></pre>

<p>It works as following:</p>

<pre><code>$ curl 107.23.20.188/get | jq
{
  "args": {},
  "headers": {
    "x-forwarded-proto": "http",
    "x-forwarded-port": "80",
    "host": "107.23.20.188",
    "x-amzn-trace-id": "Root=1-5ebced9c-941e363cc28bf3529b8e7246",
    "user-agent": "curl/7.52.1",
    "accept": "*/*"
  },
  "url": "http://107.23.20.188/get"
}
</code></pre>

<p>So as you can see it sends me a json with all headers that I sent to it and most importantly - url with path it receives.</p>

<p>Here is the ingress yaml I used:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: external-service
  annotations:
    #kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host:
    http:
      paths:
      - backend:
          serviceName: external-ip
          servicePort: 80
        path: /es/(.*)
</code></pre>

<p>Service and Endpoint definition stays the same as yours with exception for endpoint IP. Here I used 107.23.20.188 (the postman-echo IP).</p>

<p>Now lets try to send some requests through nginx but first lets check whats ingress ip:</p>

<pre><code>$ kubectl get ingress
NAME               HOSTS   ADDRESS         PORTS   AGE
external-service   *       192.168.39.96   80      20h
</code></pre>

<p>The ip is <code>192.168.39.96</code> and its private IP because I am running it on minikube but it should not matter.</p>

<pre><code>$ curl -s 192.168.39.96/es/get
{
  "args": {},
  "headers": {
    "x-forwarded-proto": "http",
    "x-forwarded-port": "80",
    "host": "192.168.39.96",
    "x-amzn-trace-id": "Root=1-5ebcf259-6331e8c709656623f1a94ed4",
    "x-request-id": "d1545d1e8764da3cf57abb143faac4fb",
    "x-forwarded-host": "192.168.39.96",
    "x-original-uri": "/es/get",
    "x-scheme": "http",
    "user-agent": "curl/7.52.1",
    "accept": "*/*"
  },
  "url": "http://192.168.39.96/get"
}
</code></pre>

<p>so as you see I am sending request for path <code>/es/get</code> and echo server is receiving <code>/get</code>.</p>

<hr>

<p>One thing I have noticed while writing this answer is that (maybe its just copy-paste error but) your quotes in annotations <code>”</code> are different than <code>"</code> and this may be causing that nginx is not processing annotations as it should. Im my case for some reason when I was copy-pasting your yaml it it was working but so it did without your annotations so that may be the reason I haven't noticed it earlier.</p>
