I have a kubernetes cluster with a NodeJS micro-service. The micro-service has an endpoint that is accessible from inside the cluster as well as outside of the cluster through an nginx reverse proxy.
I would like to be able to detect inside this endpoint whether the incoming request comes from inside or outside the cluster.
Since I would like the deployment of this NodeJS app to be flawless no matter which kubernetes platform I deploy it, I don't want to use static IP check. I have few ideas but don't know which approach is the best and how to implement it.
- Detect the local address and check if it's in the same IP prefix (not sure if nginx will return it's own IP so that might not work)
- Detect if it comes from nginx - not sure if there is a default header that can't be removed by the client or anything that can be detected from ExpressJS
- Detect somehow if it comes from a service inside the cluster (maybe there is a header or something that would indicate me that it's part of the same cluster)
I would like to know which idea (maybe not in this list) to pick and how I implement it in ExpressJS.