<p>I have 3 ingress pointing to the same service. In my kubernetes pod, how can i find the hostname  and from which subdomain request is coming . my backend code in golang server.<br />
when the request comes to any pod, i want to know from which subdomain(x,y,x) request has come to pod. Currently in the golang code it's giving hostname as pod ip address</p>
<pre><code>kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/browser-xss-filter: 'true'
    ingress.kubernetes.io/force-hsts: 'true'
    ingress.kubernetes.io/hsts-include-subdomains: 'true'
    ingress.kubernetes.io/hsts-max-age: '315360000'
  name: test
  namespace: test
spec:
  rules:
    - host: http://x.test.com
      http:
        paths:
          - backend:
              serviceName: test-service
              servicePort: 8080
            path: /
    - host: http://y.test.com
      http:
          paths:
            - backend:
                serviceName: test-service
                servicePort: 8080
              path: /
    - host: http://z.test.com
      http:
          paths:
            - backend:
                serviceName: test-service
                servicePort: 8080
              path: /
</code></pre>
<pre><code>func Subdomain( r *http.Request) {
 host := r.URL.Host
host = strings.TrimSpace(host)
//Figure out if a subdomain exists in the host given.
host_parts := strings.Split(host, &quot;.&quot;)
if len(host_parts) &gt; 2 {
    //The subdomain exists, we store it as the first element 
    //in a new array
    subdomain := []string{host_parts[0]}
}
}
</code></pre>

user1844634
<p>Try to use the <code>X-Forwarded-Host</code> header added by the ingress controller</p>
