<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>Robert is right about the second question (Many thanks)</p>

<p>I just figured out the main question, why all my paths seemed to be rewritten to <code>/</code></p>

<p>It turns out that the path is sent to the server with the "path" as specified in the ingress configuration to the actual service.
So for example, when trying to do a GET request to <code>api.example.com/my_service/my_endpoint</code>, I was expecting <code>my_service</code> to just get the path <code>/my_endpoint</code> but it was actually getting the full <code>/my_service/my_endpoint</code></p>

<p>This seems like a pretty bad kubernetes side effect in my opinion, and the path should really be a relative rewrite.</p>

<p>In any case it's fixed now. The reason I "thought" that they were all being rewritten to simply <code>/</code> is because for some reason (logic errors I wrote into my code) my multiplexer was capturing every unknown request and sending it to my index controller. Go figure!</p>
