title: Kubernetes ingress rules for external service
body: <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>