Skip to content

Commit 2baa110

Browse files
committed
api: drop StripPort from ClientTrafficPolicy host normalization
Scope the first iteration of host normalization down to trailing-dot removal only, removing the StripPort field (Envoy's strip_any_host_port) per maintainer feedback. Signed-off-by: Salim Boulkour <salim.boulkour@algolia.com>
1 parent ff2a5fa commit 2baa110

17 files changed

Lines changed: 2 additions & 351 deletions

File tree

api/v1alpha1/hostsettings_types.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@ 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-
// 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.
16-
// If not set, no port stripping is performed (Envoy default).
17-
//
18-
// Stripping only the port that matches the listener port (Envoy's
19-
// strip_matching_host_port) is intentionally not offered: Envoy compares against the
20-
// Envoy listener port, which differs from the user-facing Gateway listener port (for
21-
// example, a Gateway listener on port 80 is translated to an Envoy listener on port
22-
// 10080). Matching-port stripping would therefore be silently ineffective for the
23-
// port clients actually use, so only unconditional stripping is exposed.
24-
//
25-
// +optional
26-
StripPort *bool `json:"stripPort,omitempty"`
2711
// StripTrailingHostDot determines if the trailing dot of the host should be removed
2812
// from the Host/Authority header before any processing of the request.
2913
// This affects the upstream host header as well. Without this option, incoming requests

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -489,22 +489,6 @@ spec:
489489
description: Host enables managing how the Host/Authority header
490490
set by clients can be normalized.
491491
properties:
492-
stripPort:
493-
description: |-
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.
499-
If not set, no port stripping is performed (Envoy default).
500-
501-
Stripping only the port that matches the listener port (Envoy's
502-
strip_matching_host_port) is intentionally not offered: Envoy compares against the
503-
Envoy listener port, which differs from the user-facing Gateway listener port (for
504-
example, a Gateway listener on port 80 is translated to an Envoy listener on port
505-
10080). Matching-port stripping would therefore be silently ineffective for the
506-
port clients actually use, so only unconditional stripping is exposed.
507-
type: boolean
508492
stripTrailingHostDot:
509493
description: |-
510494
StripTrailingHostDot determines if the trailing dot of the host should be removed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -488,22 +488,6 @@ spec:
488488
description: Host enables managing how the Host/Authority header
489489
set by clients can be normalized.
490490
properties:
491-
stripPort:
492-
description: |-
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.
498-
If not set, no port stripping is performed (Envoy default).
499-
500-
Stripping only the port that matches the listener port (Envoy's
501-
strip_matching_host_port) is intentionally not offered: Envoy compares against the
502-
Envoy listener port, which differs from the user-facing Gateway listener port (for
503-
example, a Gateway listener on port 80 is translated to an Envoy listener on port
504-
10080). Matching-port stripping would therefore be silently ineffective for the
505-
port clients actually use, so only unconditional stripping is exposed.
506-
type: boolean
507491
stripTrailingHostDot:
508492
description: |-
509493
StripTrailingHostDot determines if the trailing dot of the host should be removed

internal/gatewayapi/clienttrafficpolicy.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,11 +848,10 @@ func translateHostSettings(hostSettings *egv1a1.HostSettings, httpIR *ir.HTTPLis
848848
if hostSettings == nil {
849849
return
850850
}
851-
if hostSettings.StripPort == nil && hostSettings.StripTrailingHostDot == nil {
851+
if hostSettings.StripTrailingHostDot == nil {
852852
return
853853
}
854854
httpIR.Host = &ir.HostSettings{
855-
StripPort: ptr.Deref(hostSettings.StripPort, false),
856855
StripTrailingHostDot: ptr.Deref(hostSettings.StripTrailingHostDot, false),
857856
}
858857
}

internal/gatewayapi/testdata/clienttrafficpolicy-host-strip-port.in.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

internal/gatewayapi/testdata/clienttrafficpolicy-host-strip-port.out.yaml

Lines changed: 0 additions & 142 deletions
This file was deleted.

internal/ir/xds.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,6 @@ type PathSettings struct {
594594
// HostSettings holds configuration for Host/Authority header normalization
595595
// +k8s:deepcopy-gen=true
596596
type HostSettings struct {
597-
// StripPort strips the port from the Host/Authority header unconditionally
598-
// (Envoy's strip_any_host_port). A false value means no port stripping is performed.
599-
StripPort bool `json:"stripPort,omitempty" yaml:"stripPort,omitempty"`
600597
// StripTrailingHostDot strips the trailing dot from the Host/Authority header before processing.
601598
StripTrailingHostDot bool `json:"stripTrailingHostDot,omitempty" yaml:"stripTrailingHostDot,omitempty"`
602599
}

internal/xds/translator/listener.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,7 @@ func (t *Translator) addHCMToXDSListener(
402402
}
403403

404404
// Normalize the Host/Authority header if configured.
405-
// StripAnyHostPort uses the strip_port_mode oneof, so it must be assigned outside the
406-
// struct literal to avoid a typed-nil that silently breaks xDS translation.
407405
if irListener.Host != nil {
408-
if irListener.Host.StripPort {
409-
mgr.StripPortMode = &hcmv3.HttpConnectionManager_StripAnyHostPort{StripAnyHostPort: true}
410-
}
411406
mgr.StripTrailingHostDot = irListener.Host.StripTrailingHostDot
412407
}
413408

internal/xds/translator/testdata/in/xds-ir/host-normalization.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ http:
1515
port: 8081
1616
name: "first-route-dest/backend/0"
1717
host:
18-
stripPort: true
1918
stripTrailingHostDot: true
2019
- name: "second-listener"
2120
address: "::"
@@ -32,8 +31,6 @@ http:
3231
- host: "2.2.2.2"
3332
port: 8082
3433
name: "second-route-dest/backend/0"
35-
host:
36-
stripPort: true
3734
- name: "third-listener"
3835
address: "::"
3936
port: 8083

0 commit comments

Comments
 (0)