|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * ingress/ingress-operator.adoc |
| 4 | + |
| 5 | +[id="nw-ingress-converting-http-header-case_{context}"] |
| 6 | += Converting HTTP header case |
| 7 | + |
| 8 | +HAProxy 2.2 lowercases HTTP header names by default, for example, changing `Host: xyz.com` to `host: xyz.com`. If legacy applications are sensitive to the capitalization of HTTP header names, use the Ingress Controller `spec.httpHeaders.headerNameCaseAdjustments` API field for a solution to accommodate legacy applications until they can be fixed. |
| 9 | + |
| 10 | +[IMPORTANT] |
| 11 | +==== |
| 12 | +Because {product-title} 4.8 includes HAProxy 2.2, make sure to add the necessary configuration by using `spec.httpHeaders.headerNameCaseAdjustments` before upgrading. |
| 13 | +==== |
| 14 | + |
| 15 | +.Prerequisites |
| 16 | + |
| 17 | +* You have installed the OpenShift CLI (`oc`). |
| 18 | +* You have access to the cluster as a user with the `cluster-admin` role. |
| 19 | + |
| 20 | +.Procedure |
| 21 | + |
| 22 | +As a cluster administrator, you can convert the HTTP header case by entering the `oc patch` command or by setting the `HeaderNameCaseAdjustments` field in the Ingress Controller YAML file. |
| 23 | + |
| 24 | +* Specify an HTTP header to be capitalized by entering the `oc patch` command. |
| 25 | + |
| 26 | +. Enter the `oc patch` command to change the HTTP `host` header to `Host`: |
| 27 | ++ |
| 28 | +[source,terminal] |
| 29 | +---- |
| 30 | +$ oc -n openshift-ingress-operator patch ingresscontrollers/default --type=merge --patch='{"spec":{"httpHeaders":{"headerNameCaseAdjustments":["Host"]}}}' |
| 31 | +---- |
| 32 | ++ |
| 33 | +. Annotate the route of the application: |
| 34 | ++ |
| 35 | +[source,terminal] |
| 36 | +---- |
| 37 | +$ oc annotate routes/my-application haproxy.router.openshift.io/h1-adjust-case=true |
| 38 | +---- |
| 39 | ++ |
| 40 | +The Ingress Controller then adjusts the `host` request header as specified. |
| 41 | + |
| 42 | +//Extra example if needed |
| 43 | +//// |
| 44 | +* This example changes the HTTP `cache-control` header to `Cache-Control`: |
| 45 | ++ |
| 46 | +[source,terminal] |
| 47 | +---- |
| 48 | +$ oc -n openshift-ingress-operator patch ingresscontrollers/default --type=json --patch='[{"op":"add","path":"/spec/httpHeaders/headerNameCaseAdjustments/-","value":"Cache-Control"}]' |
| 49 | +---- |
| 50 | ++ |
| 51 | +The Ingress Controller adjusts the `cache-control` response header as specified. |
| 52 | +//// |
| 53 | + |
| 54 | +* Specify adjustments using the `HeaderNameCaseAdjustments` field by configuring the Ingress Controller YAML file. |
| 55 | + |
| 56 | +. The following example Ingress Controller YAML adjusts the `host` header to `Host` for HTTP/1 requests to appropriately annotated routes: |
| 57 | ++ |
| 58 | +.Example Ingress Controller YAML |
| 59 | +[source,yaml] |
| 60 | +---- |
| 61 | +apiVersion: operator.openshift.io/v1 |
| 62 | +kind: IngressController |
| 63 | +metadata: |
| 64 | + name: default |
| 65 | + namespace: openshift-ingress-operator |
| 66 | +spec: |
| 67 | + httpHeaders: |
| 68 | + headerNameCaseAdjustments: |
| 69 | + - Host |
| 70 | +---- |
| 71 | ++ |
| 72 | +. The following example route enables HTTP response header name case adjustments using the `haproxy.router.openshift.io/h1-adjust-case` annotation: |
| 73 | ++ |
| 74 | +.Example route YAML |
| 75 | +[source,yaml] |
| 76 | +---- |
| 77 | +apiVersion: route.openshift.io/v1 |
| 78 | +kind: Route |
| 79 | +metadata: |
| 80 | + annotations: |
| 81 | + haproxy.router.openshift.io/h1-adjust-case: true <1> |
| 82 | + name: my-application |
| 83 | + namespace: my-application |
| 84 | +spec: |
| 85 | + to: |
| 86 | + kind: Service |
| 87 | + name: my-application |
| 88 | +---- |
| 89 | +<1> Set `haproxy.router.openshift.io/h1-adjust-case` to true. |
0 commit comments