Skip to content

Commit 38346c5

Browse files
authored
StripTrailingHostDot: Expose new configuration option to enable Envoy removal of trailing dot on hostnames (#6792)
* Add strip trailing host dot option from Envoy Signed-off-by: David Sale <[email protected]> * Rebase from main and apply code review suggestions Signed-off-by: David Sale <[email protected]> * Add missing changelog file for the PR 6792 Signed-off-by: David Sale <[email protected]> --------- Signed-off-by: David Sale <[email protected]>
1 parent 39c7cb9 commit 38346c5

File tree

22 files changed

+355
-16
lines changed

22 files changed

+355
-16
lines changed

apis/projectcontour/v1alpha1/contourconfig.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,19 @@ type NetworkParameters struct {
736736
// Contour's default is 9001.
737737
// +optional
738738
EnvoyAdminPort *int `json:"adminPort,omitempty"`
739+
740+
// EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
741+
// before any processing of request by HTTP filters or routing. This
742+
// affects the upstream host header. Without setting this option to true, incoming
743+
// requests with host example.com. will not match against route with domains
744+
// match set to example.com.
745+
//
746+
// See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
747+
// for more information.
748+
//
749+
// Contour's default is false.
750+
// +optional
751+
EnvoyStripTrailingHostDot *bool `json:"stripTrailingHostDot,omitempty"`
739752
}
740753

741754
// RateLimitServiceConfig defines properties of a global Rate Limit Service.

apis/projectcontour/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adds a new configuration option `strip-trailing-host-dot` which defines if trailing dot of the host should be removed from host/authority header before any processing of request by HTTP filters or routing.

cmd/contour/serve.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ func (s *Server) doServe() error {
464464
MergeSlashes: !*contourConfiguration.Envoy.Listener.DisableMergeSlashes,
465465
ServerHeaderTransformation: contourConfiguration.Envoy.Listener.ServerHeaderTransformation,
466466
XffNumTrustedHops: *contourConfiguration.Envoy.Network.XffNumTrustedHops,
467+
StripTrailingHostDot: *contourConfiguration.Envoy.Network.EnvoyStripTrailingHostDot,
467468
ConnectionBalancer: contourConfiguration.Envoy.Listener.ConnectionBalancer,
468469
MaxRequestsPerConnection: contourConfiguration.Envoy.Listener.MaxRequestsPerConnection,
469470
HTTP2MaxConcurrentStreams: contourConfiguration.Envoy.Listener.HTTP2MaxConcurrentStreams,

cmd/contour/servecontext.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,9 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_v1alpha1.Co
580580
},
581581
},
582582
Network: &contour_v1alpha1.NetworkParameters{
583-
XffNumTrustedHops: &ctx.Config.Network.XffNumTrustedHops,
584-
EnvoyAdminPort: &ctx.Config.Network.EnvoyAdminPort,
583+
XffNumTrustedHops: &ctx.Config.Network.XffNumTrustedHops,
584+
EnvoyAdminPort: &ctx.Config.Network.EnvoyAdminPort,
585+
EnvoyStripTrailingHostDot: &ctx.Config.Network.EnvoyStripTrailingHostDot,
585586
},
586587
},
587588
Gateway: gatewayConfig,

cmd/contour/servecontext_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,9 @@ func TestConvertServeContext(t *testing.T) {
483483
},
484484
},
485485
Network: &contour_v1alpha1.NetworkParameters{
486-
EnvoyAdminPort: ptr.To(9001),
487-
XffNumTrustedHops: ptr.To(uint32(0)),
486+
EnvoyAdminPort: ptr.To(9001),
487+
XffNumTrustedHops: ptr.To(uint32(0)),
488+
EnvoyStripTrailingHostDot: ptr.To(false),
488489
},
489490
},
490491
Gateway: nil,

examples/contour/01-crds.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,17 @@ spec:
521521
Contour's default is 0.
522522
format: int32
523523
type: integer
524+
stripTrailingHostDot:
525+
description: |-
526+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
527+
before any processing of request by HTTP filters or routing. This
528+
affects the upstream host header. Without setting this option to true, incoming
529+
requests with host example.com. will not match against route with domains
530+
match set to example.com.
531+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
532+
for more information.
533+
Contour's default is false.
534+
type: boolean
524535
type: object
525536
service:
526537
description: |-
@@ -4337,6 +4348,17 @@ spec:
43374348
Contour's default is 0.
43384349
format: int32
43394350
type: integer
4351+
stripTrailingHostDot:
4352+
description: |-
4353+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
4354+
before any processing of request by HTTP filters or routing. This
4355+
affects the upstream host header. Without setting this option to true, incoming
4356+
requests with host example.com. will not match against route with domains
4357+
match set to example.com.
4358+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
4359+
for more information.
4360+
Contour's default is false.
4361+
type: boolean
43404362
type: object
43414363
service:
43424364
description: |-

examples/render/contour-deployment.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,17 @@ spec:
736736
Contour's default is 0.
737737
format: int32
738738
type: integer
739+
stripTrailingHostDot:
740+
description: |-
741+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
742+
before any processing of request by HTTP filters or routing. This
743+
affects the upstream host header. Without setting this option to true, incoming
744+
requests with host example.com. will not match against route with domains
745+
match set to example.com.
746+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
747+
for more information.
748+
Contour's default is false.
749+
type: boolean
739750
type: object
740751
service:
741752
description: |-
@@ -4552,6 +4563,17 @@ spec:
45524563
Contour's default is 0.
45534564
format: int32
45544565
type: integer
4566+
stripTrailingHostDot:
4567+
description: |-
4568+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
4569+
before any processing of request by HTTP filters or routing. This
4570+
affects the upstream host header. Without setting this option to true, incoming
4571+
requests with host example.com. will not match against route with domains
4572+
match set to example.com.
4573+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
4574+
for more information.
4575+
Contour's default is false.
4576+
type: boolean
45554577
type: object
45564578
service:
45574579
description: |-

examples/render/contour-gateway-provisioner.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,17 @@ spec:
532532
Contour's default is 0.
533533
format: int32
534534
type: integer
535+
stripTrailingHostDot:
536+
description: |-
537+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
538+
before any processing of request by HTTP filters or routing. This
539+
affects the upstream host header. Without setting this option to true, incoming
540+
requests with host example.com. will not match against route with domains
541+
match set to example.com.
542+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
543+
for more information.
544+
Contour's default is false.
545+
type: boolean
535546
type: object
536547
service:
537548
description: |-
@@ -4348,6 +4359,17 @@ spec:
43484359
Contour's default is 0.
43494360
format: int32
43504361
type: integer
4362+
stripTrailingHostDot:
4363+
description: |-
4364+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
4365+
before any processing of request by HTTP filters or routing. This
4366+
affects the upstream host header. Without setting this option to true, incoming
4367+
requests with host example.com. will not match against route with domains
4368+
match set to example.com.
4369+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
4370+
for more information.
4371+
Contour's default is false.
4372+
type: boolean
43514373
type: object
43524374
service:
43534375
description: |-

examples/render/contour-gateway.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,17 @@ spec:
557557
Contour's default is 0.
558558
format: int32
559559
type: integer
560+
stripTrailingHostDot:
561+
description: |-
562+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
563+
before any processing of request by HTTP filters or routing. This
564+
affects the upstream host header. Without setting this option to true, incoming
565+
requests with host example.com. will not match against route with domains
566+
match set to example.com.
567+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
568+
for more information.
569+
Contour's default is false.
570+
type: boolean
560571
type: object
561572
service:
562573
description: |-
@@ -4373,6 +4384,17 @@ spec:
43734384
Contour's default is 0.
43744385
format: int32
43754386
type: integer
4387+
stripTrailingHostDot:
4388+
description: |-
4389+
EnvoyStripTrailingHostDot defines if trailing dot of the host should be removed from host/authority header
4390+
before any processing of request by HTTP filters or routing. This
4391+
affects the upstream host header. Without setting this option to true, incoming
4392+
requests with host example.com. will not match against route with domains
4393+
match set to example.com.
4394+
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto?highlight=strip_trailing_host_dot
4395+
for more information.
4396+
Contour's default is false.
4397+
type: boolean
43764398
type: object
43774399
service:
43784400
description: |-

0 commit comments

Comments
 (0)