Skip to content

Commit 0c84493

Browse files
Add hop_by_hop_headers_to_filter property (#331)
Add `router.hop_by_hop_headers_to_filter` property to `gorouter` job with default values set to: - X-Forwarded-For - X-Forwarded-Proto - B3 - X-B3 - X-B3-SpanID - X-B3-TraceID - X-Request-Start - X-Forwarded-Client-Cert Associated `gorouter` PR: - cloudfoundry/gorouter#356 [#185767952](https://www.pivotaltracker.com/story/show/185767952) Co-authored-by: Josh Russett <[email protected]>
1 parent 6c2f0d5 commit 0c84493

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

jobs/gorouter/spec

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,27 @@ properties:
282282
example:
283283
- name: X-Vcap-Request-Id
284284
- name: Accept-Ranges
285+
router.hop_by_hop_headers_to_filter:
286+
description: |
287+
(optional, array value) List of HTTP Headers that are filtered for
288+
Hop-By-Hop Connection header.
289+
When clients make requests to the gorouter and the gorouter proxies
290+
their request, these HTTP Headers will be automatically be removed from
291+
the request's Connection header and sent as normal headers to the
292+
target backend. This list *also* specificies the Headers that can be
293+
returned by the backend; i.e. if a client attempts to send one of these
294+
Headers in their Connection Header to gorouter and it's *NOT* filtered,
295+
the header will *NOT* be returned to client properly after proxying the
296+
request.
297+
default:
298+
- X-Forwarded-For
299+
- X-Forwarded-Proto
300+
- B3
301+
- X-B3
302+
- X-B3-SpanID
303+
- X-B3-TraceID
304+
- X-Request-Start
305+
- X-Forwarded-Client-Cert
285306
router.frontend_idle_timeout:
286307
description: |
287308
(optional, integer) Duration in seconds to maintain an open connection when client supports keep-alive.

jobs/gorouter/templates/gorouter.yml.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ params = {
106106
'enable_proxy' => p('router.enable_proxy'),
107107
'force_forwarded_proto_https' => p('router.force_forwarded_proto_https'),
108108
'sanitize_forwarded_proto' => p('router.sanitize_forwarded_proto'),
109+
'hop_by_hop_headers_to_filter' => p('router.hop_by_hop_headers_to_filter'),
109110
'pid_file' => '/var/vcap/sys/run/gorouter/gorouter.pid',
110111
'ip_local_port_range' => p('router.ip_local_port_range'),
111112
'empty_pool_response_code_503' => p('for_backwards_compatibility_only.empty_pool_response_code_503'), # backwards compatibility only section

spec/gorouter_templates_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
'enable_proxy' => false,
174174
'force_forwarded_proto_https' => false,
175175
'sanitize_forwarded_proto' => false,
176+
'hop_by_hop_headers_to_filter' => ["X-ME", "X-Foo"],
176177
'suspend_pruning_if_nats_unavailable' => false,
177178
'max_idle_connections' => 100,
178179
'keep_alive_probe_interval' => '1s',
@@ -368,6 +369,12 @@
368369
end
369370
end
370371

372+
describe 'hop_by_hop_headers_to_filter' do
373+
it 'should set hop_by_hop_headers_to_filter' do
374+
expect(parsed_yaml['hop_by_hop_headers_to_filter']).to eq(["X-ME","X-Foo"])
375+
end
376+
end
377+
371378
context 'route_services_internal_lookup' do
372379
it 'defaults to false' do
373380
expect(parsed_yaml['route_services_hairpinning']).to eq(false)

0 commit comments

Comments
 (0)