In-cluster nginx proxy (sidecar) in Kubernetes to re-write headers

3/10/2020

Background

I have an in-cluster Kubernetes pod/application that works fine when accessing it via an nginx-ingress ingress controller (requires specific Host HTTP header), but it cannot be accessed by other in-cluster pods/applications (i.e. for testing) due to the pods using different host names (e.g. service-name.namespace.svc.cluster.local) rather than the FQDN of the K8S master (in the LAN).


Plan So Far

I think the only way to (easily) resolve this is to setup an in-cluster forward-proxy nginx instance. Ideally, the service is either a side-car for the pod that needs to have headers re-written, or it needs to be a general in-cluster proxy that multiple services can access.


Question

  • How would I setup an in-cluster nginx forward proxy service?
  • Should it be a sidecar, or a general service any pod can access?

Work So Far

The linked "similar" questions don't appear to be helpful for my use case (i.e. don't show how to configure an in-cluster proxy), or are focused on proxying to IPs external to the cluster (i.e. I need to proxy HTTP requests, and re-write their headers, to in-cluster resources).

-- Superbad
http-headers
http-proxy
kubernetes
nginx
nginx-ingress

0 Answers