<p>I have two Node.js/Express services run on Azure/Kubernetes.
Then I send HTTP request to Service1 which is forwarding the request to Service2.
How Service2 knows that the request came from Service1?</p>
<p>HTTP/POST/GET =&gt; Service1 =&gt; Service2</p>
<p>console.log(request.headers.host) prints &quot;Service2&quot;</p>
<p>I do not want to modify the request in Service1 by adding extra info/data/fields.
So how do Service2 knows it came from Service1?</p>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p>update: I though this way I can reject some requests if they come from other services. Should I have it done through K8s Network Policy?</p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>

John Glabb
<p><code>Host</code> header is the address that the client is trying to reach, which is not what you want. <code>Origin</code> header will give you the source ip, but not a friendly service name, so to get that you would have to somehow map the IP back to a service, which is not simple to do since pods will typically get an new, unpredictable IP when they are created.</p>
<p>You could use the Kubernetes API to reverse lookup ip addresses for a service name, but that's a pretty bad design imo.</p>
<p>Ideally, you would have the client service add headers or data in the body with info about the calling service.</p>
<p>You might also be able to use a service mesh for Kubernetes (ie. istio, linkerd) which can inject information without needing to modify the original service.</p>
