Skip to content

Commit fb22700

Browse files
authored
Merge pull request #32287 from bmcelvee/OSDOCS-2134
OSDOCS-2134 procedure for converting HTTP header case
2 parents 352a72e + f5d1e54 commit fb22700

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

modules/nw-ingress-controller-configuration-parameters.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ By default, the policy is set to `Append`.
146146
* `IfNone` specifies that the Ingress Controller sets the headers if they are not already set.
147147
* `Never` specifies that the Ingress Controller never sets the headers, preserving any existing headers.
148148

149+
By setting `headerNameCaseAdjustments`, you can specify case adjustments that can be applied to HTTP header names. Each adjustment is specified as an HTTP header name with the desired capitalization. For example, specifying `X-Forwarded-For` indicates that the `x-forwarded-for` HTTP header should be adjusted to have the specified capitalization.
150+
151+
These adjustments are only applied to cleartext, edge-terminated, and re-encrypt routes, and only when using HTTP/1.
152+
153+
For request headers, these adjustments are applied only for routes that have the `haproxy.router.openshift.io/h1-adjust-case=true` annotation. For response headers, these adjustments are applied to all HTTP responses. If this field is empty, no request headers are adjusted.
154+
149155
|===
150156

151157

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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.

networking/ingress-operator.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ include::modules/nw-http2-haproxy.adoc[leveloffset=+2]
6060

6161
include::modules/nw-ingress-configuring-application-domain.adoc[leveloffset=+2]
6262

63+
include::modules/nw-ingress-converting-http-header-case.adoc[leveloffset=+2]
64+
6365
//include::modules/nw-ingress-select-route.adoc[leveloffset=+2]
6466

6567
== Additional resources

0 commit comments

Comments
 (0)