Skip to content

Commit ff2a5fa

Browse files
committed
api: clarify StripPort normalizes the forwarded Host header
Address Copilot review on #9115: Envoy's strip_any_host_port not only strips the port for route matching but also normalizes the actual Host/:authority value forwarded upstream. Make the StripPort godoc state this explicitly (mirroring StripTrailingHostDot's upstream-header note), so the generated CRD/API docs reflect the real effect. Regenerated CRDs, helm snapshots and API docs. Signed-off-by: Salim Boulkour <salim.boulkour@algolia.com>
1 parent 9c49b33 commit ff2a5fa

7 files changed

Lines changed: 31 additions & 19 deletions

File tree

api/v1alpha1/hostsettings_types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ package v1alpha1
88
// HostSettings provides settings that manage how the incoming Host/Authority header
99
// set by clients is normalized.
1010
type HostSettings struct {
11-
// StripPort determines whether the port is removed from the Host/Authority header
12-
// before route matching. It maps to Envoy's strip_any_host_port, which strips the
13-
// port unconditionally.
11+
// StripPort determines whether the port is removed from the Host/Authority header.
12+
// It maps to Envoy's strip_any_host_port, which strips the port unconditionally.
13+
// The port is removed before route matching, and this affects the upstream host header
14+
// as well: backends and access logs see the normalized Host/:authority value without
15+
// the port.
1416
// If not set, no port stripping is performed (Envoy default).
1517
//
1618
// Stripping only the port that matches the listener port (Envoy's

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,11 @@ spec:
491491
properties:
492492
stripPort:
493493
description: |-
494-
StripPort determines whether the port is removed from the Host/Authority header
495-
before route matching. It maps to Envoy's strip_any_host_port, which strips the
496-
port unconditionally.
494+
StripPort determines whether the port is removed from the Host/Authority header.
495+
It maps to Envoy's strip_any_host_port, which strips the port unconditionally.
496+
The port is removed before route matching, and this affects the upstream host header
497+
as well: backends and access logs see the normalized Host/:authority value without
498+
the port.
497499
If not set, no port stripping is performed (Envoy default).
498500
499501
Stripping only the port that matches the listener port (Envoy's

charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,11 @@ spec:
490490
properties:
491491
stripPort:
492492
description: |-
493-
StripPort determines whether the port is removed from the Host/Authority header
494-
before route matching. It maps to Envoy's strip_any_host_port, which strips the
495-
port unconditionally.
493+
StripPort determines whether the port is removed from the Host/Authority header.
494+
It maps to Envoy's strip_any_host_port, which strips the port unconditionally.
495+
The port is removed before route matching, and this affects the upstream host header
496+
as well: backends and access logs see the normalized Host/:authority value without
497+
the port.
496498
If not set, no port stripping is performed (Envoy default).
497499
498500
Stripping only the port that matches the listener port (Envoy's

site/content/en/latest/api/extension_types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3377,7 +3377,7 @@ _Appears in:_
33773377

33783378
| Field | Type | Required | Default | Description |
33793379
| --- | --- | --- | --- | --- |
3380-
| `stripPort` | _boolean_ | false | | StripPort determines whether the port is removed from the Host/Authority header<br />before route matching. It maps to Envoy's strip_any_host_port, which strips the<br />port unconditionally.<br />If not set, no port stripping is performed (Envoy default).<br />Stripping only the port that matches the listener port (Envoy's<br />strip_matching_host_port) is intentionally not offered: Envoy compares against the<br />Envoy listener port, which differs from the user-facing Gateway listener port (for<br />example, a Gateway listener on port 80 is translated to an Envoy listener on port<br />10080). Matching-port stripping would therefore be silently ineffective for the<br />port clients actually use, so only unconditional stripping is exposed. |
3380+
| `stripPort` | _boolean_ | false | | StripPort determines whether the port is removed from the Host/Authority header.<br />It maps to Envoy's strip_any_host_port, which strips the port unconditionally.<br />The port is removed before route matching, and this affects the upstream host header<br />as well: backends and access logs see the normalized Host/:authority value without<br />the port.<br />If not set, no port stripping is performed (Envoy default).<br />Stripping only the port that matches the listener port (Envoy's<br />strip_matching_host_port) is intentionally not offered: Envoy compares against the<br />Envoy listener port, which differs from the user-facing Gateway listener port (for<br />example, a Gateway listener on port 80 is translated to an Envoy listener on port<br />10080). Matching-port stripping would therefore be silently ineffective for the<br />port clients actually use, so only unconditional stripping is exposed. |
33813381
| `stripTrailingHostDot` | _boolean_ | false | | StripTrailingHostDot determines if the trailing dot of the host should be removed<br />from the Host/Authority header before any processing of the request.<br />This affects the upstream host header as well. Without this option, incoming requests<br />with host "example.com." will not match routes with domains set to "example.com".<br />When the host includes a port (for example "example.com.:443"), only the trailing dot<br />from the host section is stripped, leaving the port as-is ("example.com:443").<br />Defaults to false. |
33823382

33833383

test/helm/gateway-crds-helm/all.out.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26773,9 +26773,11 @@ spec:
2677326773
properties:
2677426774
stripPort:
2677526775
description: |-
26776-
StripPort determines whether the port is removed from the Host/Authority header
26777-
before route matching. It maps to Envoy's strip_any_host_port, which strips the
26778-
port unconditionally.
26776+
StripPort determines whether the port is removed from the Host/Authority header.
26777+
It maps to Envoy's strip_any_host_port, which strips the port unconditionally.
26778+
The port is removed before route matching, and this affects the upstream host header
26779+
as well: backends and access logs see the normalized Host/:authority value without
26780+
the port.
2677926781
If not set, no port stripping is performed (Envoy default).
2678026782

2678126783
Stripping only the port that matches the listener port (Envoy's

test/helm/gateway-crds-helm/e2e.out.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,9 +4746,11 @@ spec:
47464746
properties:
47474747
stripPort:
47484748
description: |-
4749-
StripPort determines whether the port is removed from the Host/Authority header
4750-
before route matching. It maps to Envoy's strip_any_host_port, which strips the
4751-
port unconditionally.
4749+
StripPort determines whether the port is removed from the Host/Authority header.
4750+
It maps to Envoy's strip_any_host_port, which strips the port unconditionally.
4751+
The port is removed before route matching, and this affects the upstream host header
4752+
as well: backends and access logs see the normalized Host/:authority value without
4753+
the port.
47524754
If not set, no port stripping is performed (Envoy default).
47534755

47544756
Stripping only the port that matches the listener port (Envoy's

test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,9 +4746,11 @@ spec:
47464746
properties:
47474747
stripPort:
47484748
description: |-
4749-
StripPort determines whether the port is removed from the Host/Authority header
4750-
before route matching. It maps to Envoy's strip_any_host_port, which strips the
4751-
port unconditionally.
4749+
StripPort determines whether the port is removed from the Host/Authority header.
4750+
It maps to Envoy's strip_any_host_port, which strips the port unconditionally.
4751+
The port is removed before route matching, and this affects the upstream host header
4752+
as well: backends and access logs see the normalized Host/:authority value without
4753+
the port.
47524754
If not set, no port stripping is performed (Envoy default).
47534755

47544756
Stripping only the port that matches the listener port (Envoy's

0 commit comments

Comments
 (0)