ingress-nginx-helm/docs/examples/customization/custom-headers
iugastefan922 5c6a28464b
additional info for the custom-headers documentation page (#7603)
* added another documentation example

* added end of file newline

* Revert "added end of file newline"

This reverts commit 2d196ffba3.

* added another documentation example
2021-09-16 14:23:27 -07:00
..
configmap-client-response.yaml additional info for the custom-headers documentation page (#7603) 2021-09-16 14:23:27 -07:00
configmap.yaml Use ingress-nginx-* naming in docs to match the default deployment 2020-05-17 21:27:56 +03:00
custom-headers.yaml Update documentation and examples [ci skip] 2017-10-16 09:55:46 -03:00
README.md additional info for the custom-headers documentation page (#7603) 2021-09-16 14:23:27 -07:00

Custom Headers

This example demonstrates configuration of the nginx ingress controller via a ConfigMap to pass a custom list of headers to the upstream server.

custom-headers.yaml defines a ConfigMap in the ingress-nginx namespace named custom-headers, holding several custom X-prefixed HTTP headers.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/custom-headers/custom-headers.yaml

configmap.yaml defines a ConfigMap in the ingress-nginx namespace named ingress-nginx-controller. This controls the global configuration of the ingress controller, and already exists in a standard installation. The key proxy-set-headers is set to cite the previously-created ingress-nginx/custom-headers ConfigMap.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/custom-headers/configmap.yaml

The nginx ingress controller will read the ingress-nginx/ingress-nginx-controller ConfigMap, find the proxy-set-headers key, read HTTP headers from the ingress-nginx/custom-headers ConfigMap, and include those HTTP headers in all requests flowing from nginx to the backends.

The above example was for passing a custom list of headers to the upstream server. To pass the custom headers before sending response traffic to the client, use the add-headers key:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/custom-headers/configmap-client-response.yaml

Test

Check the contents of the ConfigMaps are present in the nginx.conf file using: kubectl exec ingress-nginx-controller-873061567-4n3k2 -n ingress-nginx -- cat /etc/nginx/nginx.conf