|
6 | 6 | [id="nw-ingress-converting-http-header-case_{context}"]
|
7 | 7 | = Converting HTTP header case
|
8 | 8 |
|
9 |
| -HAProxy 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 | +HAProxy 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. |
10 | 10 |
|
11 | 11 | [IMPORTANT]
|
12 | 12 | ====
|
13 |
| -Because {product-title} includes HAProxy 2.8, be sure to add the necessary configuration by using `spec.httpHeaders.headerNameCaseAdjustments` before upgrading. |
| 13 | +{product-title} includes HAProxy 2.8. If you want to update to this version of the web-based load balancer, ensure that you add the `spec.httpHeaders.headerNameCaseAdjustments` section to your cluster's configuration file. |
14 | 14 | ====
|
15 | 15 |
|
| 16 | +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. |
| 17 | + |
16 | 18 | .Prerequisites
|
17 | 19 |
|
18 | 20 | * You have installed the OpenShift CLI (`oc`).
|
19 | 21 | * You have access to the cluster as a user with the `cluster-admin` role.
|
20 | 22 |
|
21 | 23 | .Procedure
|
22 | 24 |
|
23 |
| -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. |
| 25 | +* Capitalize an HTTP header by using the `oc patch` command. |
24 | 26 |
|
25 |
| -* Specify an HTTP header to be capitalized by entering the `oc patch` command. |
26 |
| -
|
27 |
| -. Enter the `oc patch` command to change the HTTP `host` header to `Host`: |
| 27 | +.. Change the HTTP header from `host` to `Host` by running the following command: |
28 | 28 | +
|
29 | 29 | [source,terminal]
|
30 | 30 | ----
|
31 | 31 | $ oc -n openshift-ingress-operator patch ingresscontrollers/default --type=merge --patch='{"spec":{"httpHeaders":{"headerNameCaseAdjustments":["Host"]}}}'
|
32 | 32 | ----
|
33 | 33 | +
|
34 |
| -. Annotate the route of the application: |
35 |
| -+ |
36 |
| -[source,terminal] |
37 |
| ----- |
38 |
| -$ oc annotate routes/my-application haproxy.router.openshift.io/h1-adjust-case=true |
39 |
| ----- |
40 |
| -+ |
41 |
| -The Ingress Controller then adjusts the `host` request header as specified. |
42 |
| - |
43 |
| -//Extra example if needed |
44 |
| -//// |
45 |
| -* This example changes the HTTP `cache-control` header to `Cache-Control`: |
| 34 | +.. Create a `Route` resource YAML file so that the annotation can be applied to the application. |
46 | 35 | +
|
47 |
| -[source,terminal] |
| 36 | +.Example of a route named `my-application` |
| 37 | +[source,yaml] |
48 | 38 | ----
|
49 |
| -$ oc -n openshift-ingress-operator patch ingresscontrollers/default --type=json --patch='[{"op":"add","path":"/spec/httpHeaders/headerNameCaseAdjustments/-","value":"Cache-Control"}]' |
| 39 | +apiVersion: route.openshift.io/v1 |
| 40 | +kind: Route |
| 41 | +metadata: |
| 42 | + annotations: |
| 43 | + haproxy.router.openshift.io/h1-adjust-case: true <1> |
| 44 | + name: <application_name> |
| 45 | + namespace: <application_name> |
| 46 | +# ... |
50 | 47 | ----
|
51 |
| -+ |
52 |
| -The Ingress Controller adjusts the `cache-control` response header as specified. |
53 |
| -//// |
| 48 | +<1> Set `haproxy.router.openshift.io/h1-adjust-case` so that the Ingress Controller can adjust the `host` request header as specified. |
54 | 49 |
|
55 |
| -* Specify adjustments using the `HeaderNameCaseAdjustments` field by configuring the Ingress Controller YAML file. |
| 50 | +* Specify adjustments by configuring the `HeaderNameCaseAdjustments` field in the Ingress Controller YAML configuration file. |
56 | 51 |
|
57 |
| -. The following example Ingress Controller YAML adjusts the `host` header to `Host` for HTTP/1 requests to appropriately annotated routes: |
| 52 | +.. The following example Ingress Controller YAML file adjusts the `host` header to `Host` for HTTP/1 requests to appropriately annotated routes: |
58 | 53 | +
|
59 | 54 | .Example Ingress Controller YAML
|
60 | 55 | [source,yaml]
|
|
70 | 65 | - Host
|
71 | 66 | ----
|
72 | 67 | +
|
73 |
| -. The following example route enables HTTP response header name case adjustments using the `haproxy.router.openshift.io/h1-adjust-case` annotation: |
| 68 | +.. The following example route enables HTTP response header name case adjustments by using the `haproxy.router.openshift.io/h1-adjust-case` annotation: |
74 | 69 | +
|
75 | 70 | .Example route YAML
|
76 | 71 | [source,yaml]
|
|
0 commit comments