<p><strong>TL;DR</strong> for some reason every http service seems to have the path rewritten as <code>/</code></p>

<p>I'm pretty new to Kubernetes and trying to set up an ingress load balancer.</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.6", GitCommit:"4bc5e7f9a6c25dc4c03d4d656f2cefd21540e28c", GitTreeState:"clean", BuildDate:"2017-09-14T06:55:55Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"7+", GitVersion:"v1.7.6-gke.1", GitCommit:"407dbfe965f3de06b332cc22d2eb1ca07fb4d3fb", GitTreeState:"clean", BuildDate:"2017-09-27T21:21:34Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>I'm setting everything up in Google Container Engine (GKE)</p>

<p>It's partially working, which is a good thing. However, for some reason it's routing everything to my service as if the request is directed at <code>/</code>.</p>

<p>What's happening here? My guess is poor configuration.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: main-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "ingress-main-ip"
spec:
  tls:
  - secretName: cert-main
    hosts:
    - api.example.com
  rules:
  - host: api.example.com
    http:
      paths:
      - path: /my_service/*
        backend:
          serviceName: myService
          servicePort: main-port
      - path: /my_service2/*
        backend:
          serviceName: myService2
          servicePort: main-port
</code></pre>

<p>Whenever I make a request to <code>api.example.com/my_service/</code> then myService will register the request as coming from index--no problem.</p>

<p>Same thing with <code>https://api.example.com/my_service2/</code> which goes to myService2</p>

<p>But whenever I make a request to <code>https://api.example.com/my_service/bogus/path/that/should/return/404</code> then my service seems to think the request is being directed at the <code>/</code> path again just as before.</p>

<p>Of course when I run myService locally (which happens to be a Go http server), then it works perfectly fine. <strong>To be especially clear:</strong> running this locally <code>127.0.0.1/bogus/path/that/should/return/404</code> <em>returns a 404 as expected</em> (and of course other API endpoints also work)</p>

<p>Here's an extremely strange thing: whenever I visit the static IP address directly  (aka ingress-main-ip, let's just say it's 1.2.3.4), for example <code>http://1.2.3.4/my_service/</code> or <code>http://1.2.3.4/my_service2/</code> it <em>always</em> returns a 404 from the GKE default backend, so my services aren't even getting routed to.</p>

<p>Summary:</p>

<ol>
<li>Why are the domain versions of the requests all routing to <code>/</code></li>
<li>Why do the direct IP requests not work at all?</li>
</ol>

<p>Thank you for your time and help!</p>

<p>I will answer the 2nd question.</p>

<p>The <em>extremely strange thing</em> is due to the HTTP header "Host" matters because you specified it in the <strong>rules</strong> section:</p>

<pre><code>rules:
  - host: api.example.com           &lt;----- THIS
    http:
      paths:
      - path: /my_service/*
        backend:
          serviceName: myService
          servicePort: main-port
      - path: /my_service2/*
        backend:
          serviceName: myService2
          servicePort: main-port
</code></pre>

<p>So it's used to route the request to the proper service. If your <em>service controller</em> is nginx, so that "host:" is its <a href="http://nginx.org/en/docs/http/server_names.html" rel="nofollow noreferrer"><em>server_name</em></a>.</p>
