a little place I like to call home.

Kubernetes Ingress With Server Host

Mar. 27, 2019

While setting up the ingress controller I needed a way to pass through the server headers from the proxied web applications. There wasn't much in the ingress annotations documentation to help me figure out how to remove the default Server: Nginx header and replace it. After hunting through different sources I was pretty sure it existed, but couldn't figure out how to disable/change it. Finally I ended up finding a GH issue that helped inform me that the ingress controller is just openresty (or uses some openresty plugins). This allowed me to figure out three key things that I needed for overriding.

First, the annotation allows you to customize nginx location.

Next was more_clear_headers Server; which removes the default Server header.

Third, was more_set_headers "Server: $upstream_http_server"; which sets the Server header to what the upstream server header returned.

Putting it all together: |
  more_clear_headers Server;
  more_set_headers "Server: $upstream_http_server";

Hopefully this helps someone else.

comments powered by Disqus