Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCM: add support for IP detection extensions #14855

Merged
merged 175 commits into from
May 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
2be9bdd
HCM: add support for IP detection extensions
Jan 28, 2021
e55d622
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Jan 28, 2021
eee3cd5
Rename --> original_ip_detection
Jan 29, 2021
e8d890a
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Jan 29, 2021
03819df
Update changelog
Jan 29, 2021
701e979
Some docs
Jan 29, 2021
68c9785
Add HCM config tests
Feb 1, 2021
c525fa0
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 1, 2021
b42737b
Add test for mutateRequestHeaders() using an extension
Feb 1, 2021
9a4421d
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 1, 2021
09a28e2
Use TypedExtensionConfig
Feb 2, 2021
2358acb
Extensive comments around the config message
Feb 2, 2021
445d0b2
Fix test
Feb 2, 2021
c8b4115
Fix another test
Feb 2, 2021
0868c1e
clang-tidy fixes
Feb 2, 2021
986f598
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 2, 2021
1552d08
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 2, 2021
d2b691a
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 3, 2021
def62d3
Add integration test
Feb 3, 2021
a44ce6f
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 4, 2021
c48840a
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 8, 2021
b8d50d9
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 11, 2021
8634819
Address Alyssa's review.
Feb 11, 2021
6193ad2
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 11, 2021
7d4d71b
Don't copy downstream_remote_address
Feb 11, 2021
b30ce45
Fix build
Feb 11, 2021
406d825
Drop struct
Feb 11, 2021
8832af6
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 11, 2021
7440409
Review feedback
Feb 12, 2021
8ebd8b8
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 12, 2021
3960337
Implement/Exercise allow_trusted_address_checks option
Feb 12, 2021
24a45b0
Drop struct
Feb 12, 2021
612ae54
Add XFF detection extension
Feb 12, 2021
2937e99
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 12, 2021
9db5c61
Use the XFF extension as the default fallback
Feb 12, 2021
3608dbf
Add support for rejecting requests when detection fails
Feb 13, 2021
1190035
Fixes for CI
Feb 13, 2021
970b42b
Fix docs
Feb 13, 2021
2e5e67f
Fix spelling
Feb 14, 2021
a23f44f
Code owners
Feb 14, 2021
5bd6813
Fix test
Feb 15, 2021
bd00e7f
Fix clang-tidy issue
Feb 15, 2021
178d287
Fix coverage
Feb 15, 2021
802c379
Check that a good detection doesn't set rejection options
Feb 15, 2021
151f5f8
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 16, 2021
8f5165b
Review comments
Feb 16, 2021
a246e9e
Add stat for ip detection rejections
Feb 16, 2021
d86f908
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 16, 2021
e2fc581
Remove possible exception from data path
Feb 16, 2021
7476d1a
Matt's review comments
Feb 17, 2021
370c16d
clang tidy
Feb 17, 2021
aa7306c
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 17, 2021
1e1ac79
Drop mostly duplicated extension for test
Feb 17, 2021
3eca009
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 17, 2021
e32eef6
More CI fixes
Feb 17, 2021
5871471
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 17, 2021
f0e29ae
Fix merge
Feb 17, 2021
92c0ed4
More cleanup
Feb 17, 2021
a20c9bb
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 17, 2021
ac430bb
Fix format
Feb 18, 2021
4446232
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 22, 2021
d2fec64
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 22, 2021
b60a227
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 24, 2021
822aa25
Fixes
Feb 24, 2021
b14fe36
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 24, 2021
a1edf65
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Feb 24, 2021
79a6282
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 3, 2021
8ad18c6
Rename config param to allow_extension_to_set_address_as_trusted
Mar 3, 2021
9a0d41b
Update header to reflect we now support a list of extensions
Mar 3, 2021
4043a4a
Alyssa's feedback
Mar 3, 2021
0bd4551
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 3, 2021
f873002
Fix deprecation error in test
Mar 3, 2021
b9d2949
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 4, 2021
cc2dc36
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 4, 2021
ca7bd7e
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 4, 2021
98bb064
Force registration of the XFF extension
Mar 4, 2021
a523594
Visibility public for XFF config
Mar 4, 2021
9861c9d
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 5, 2021
820f866
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 5, 2021
63b8f2c
Fix merge
Mar 5, 2021
4fa79d7
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 5, 2021
056db7c
Fix merge leftover
Mar 5, 2021
3885ec4
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 8, 2021
d33994c
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 9, 2021
af498c8
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 11, 2021
309b1b4
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 11, 2021
977f42b
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 12, 2021
24b9de8
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 14, 2021
d0a99c1
Fix merge
Mar 14, 2021
6a85d81
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 15, 2021
c4188ce
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 15, 2021
ab19e4d
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 16, 2021
02d9c88
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 17, 2021
684c8af
Fix merge
Mar 17, 2021
a226897
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 22, 2021
728fa54
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 24, 2021
bb2ec49
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Mar 30, 2021
8a692d6
Fix merge snafu
Mar 30, 2021
222eeae
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 2, 2021
4adad84
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 5, 2021
8568494
Add code block example for replacing xff_num_trusted_hops
Apr 5, 2021
cd9b360
Alyssa's feedback (partial)
Apr 5, 2021
0647ad9
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 6, 2021
57443bd
Fix build
Apr 6, 2021
d6bbeaa
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 6, 2021
99bd132
Fix
Apr 6, 2021
ea48936
Fix test
Apr 6, 2021
63ccd3f
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 6, 2021
7c78b24
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 6, 2021
a823d94
Address latest batch of comments
Apr 7, 2021
e4b99bc
Test for createExtension() returning nullptr
Apr 7, 2021
19180ff
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 7, 2021
f8df690
Add extension name to the exception message
Apr 7, 2021
7ce524e
Test case for v6
Apr 7, 2021
bd05e1a
clang-tidy
Apr 7, 2021
95779af
custom header: improve coverage
Apr 7, 2021
18f02c3
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 7, 2021
516de72
Set the custom header extension to out by default
Apr 7, 2021
63a3987
Update headers.rst to reflect the use of IP detection extensions
Apr 8, 2021
d0f50da
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 8, 2021
305f2ed
extensions/ -> extensions/http/
Apr 8, 2021
7fe2d81
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 8, 2021
29af4d3
Reduce (or hide) the dynamic_cast calls
Apr 8, 2021
336261c
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 8, 2021
720d541
Fix visibility comments
Apr 8, 2021
de30bd9
More comment fixes
Apr 8, 2021
ab852ff
Validate header name
Apr 8, 2021
4582469
More fixes
Apr 8, 2021
8ec2a83
More namespaces fixes
Apr 9, 2021
129b0bf
Expand integration test
Apr 9, 2021
6ac62e6
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 9, 2021
c338b65
Validate header name
Apr 9, 2021
c2717ba
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 12, 2021
800b843
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 15, 2021
5070b90
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 15, 2021
91806ca
Matt's feedback
Apr 15, 2021
5f15518
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 15, 2021
014d6d4
Update changelog
Apr 15, 2021
15dc56a
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 15, 2021
eaca63d
Fix changelog
Apr 15, 2021
9b0f98b
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 16, 2021
a241827
Fix current changelog
Apr 16, 2021
bffe4d1
Bring back the custom header extension
Apr 16, 2021
991996b
Fix format
Apr 16, 2021
73aad95
Avoid namespace pollution issues
Apr 16, 2021
6cd3d43
Another test fix
Apr 16, 2021
42776e9
Another test fix
Apr 16, 2021
7e6da84
Fix
Apr 16, 2021
ef56193
Format
Apr 16, 2021
04b19b9
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 16, 2021
66f2296
Fix integration tests
Apr 16, 2021
b78ba36
extensions/common/aws needs xff to run
Apr 16, 2021
16a736e
xff:config should have been a dep of hcm:config in the prev commit
Apr 16, 2021
fcf7945
HCM's test needs the custom header extension
Apr 18, 2021
098ecd5
clang-tidy
Apr 18, 2021
081e731
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 20, 2021
c025400
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 20, 2021
ff6b944
Undo jwt proto formatting
Apr 20, 2021
09c84e4
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 23, 2021
cef2d20
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 26, 2021
e1f0ac5
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 27, 2021
145809a
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 27, 2021
a62ede7
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
Apr 28, 2021
0eac980
Fallback -> fall back
Apr 28, 2021
c751398
Comment on allow trusted check
Apr 28, 2021
bafa351
Status code comment
Apr 28, 2021
f9a372c
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
May 13, 2021
892a4a8
Fix merge
May 13, 2021
fd10840
Trim down comment for original_ip_detection_extensions
May 13, 2021
3ef96b1
More fixes
May 13, 2021
f841b5f
Field name update
May 13, 2021
c4a21e7
Fix
May 14, 2021
166eddb
htuch's review
May 14, 2021
43ff219
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
May 14, 2021
d53e920
Merge remote-tracking branch 'upstream/main' into add-ip-detection-ex…
May 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,6 @@ extensions/filters/http/oauth2 @rgs1 @derekargueta @snowp
/*/extensions/filters/common/ext_authz @esmet @gsagula @dio
/*/extensions/filters/http/ext_authz @esmet @gsagula @dio
/*/extensions/filters/network/ext_authz @esmet @gsagula @dio
# Original IP detection
/*/extensions/http/original_ip_detection/custom_header @rgs1 @alyssawilk @antoniovicente
/*/extensions/http/original_ip_detection/xff @rgs1 @alyssawilk @antoniovicente
2 changes: 2 additions & 0 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ proto_library(
"//envoy/extensions/filters/udp/udp_proxy/v3:pkg",
"//envoy/extensions/health_checkers/redis/v3:pkg",
"//envoy/extensions/http/header_formatters/preserve_case/v3:pkg",
"//envoy/extensions/http/original_ip_detection/custom_header/v3:pkg",
"//envoy/extensions/http/original_ip_detection/xff/v3:pkg",
"//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg",
"//envoy/extensions/internal_redirect/previous_routes/v3:pkg",
"//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ licenses(["notice"]) # Apache 2

api_proto_package(
deps = [
"//envoy/annotations:pkg",
"//envoy/config/accesslog/v3:pkg",
"//envoy/config/core/v3:pkg",
"//envoy/config/filter/network/http_connection_manager/v2:pkg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/wrappers.proto";

import "envoy/annotations/deprecation.proto";
import "udpa/annotations/migrate.proto";
import "udpa/annotations/security.proto";
import "udpa/annotations/status.proto";
Expand All @@ -34,7 +35,7 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
// HTTP connection manager :ref:`configuration overview <config_http_conn_man>`.
// [#extension: envoy.filters.network.http_connection_manager]

// [#next-free-field: 46]
// [#next-free-field: 47]
message HttpConnectionManager {
option (udpa.annotations.versioning).previous_message_type =
"envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager";
Expand Down Expand Up @@ -495,7 +496,36 @@ message HttpConnectionManager {
// determining the origin client's IP address. The default is zero if this option
// is not specified. See the documentation for
// :ref:`config_http_conn_man_headers_x-forwarded-for` for more information.
uint32 xff_num_trusted_hops = 19;
//
// .. note::
// This field is deprecated and instead :ref:`original_ip_detection_extensions
// <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.original_ip_detection_extensions>`
// should be used to configure the :ref:`xff extension <envoy_v3_api_msg_extensions.http.original_ip_detection.xff.v3.XffConfig>`
// to configure IP detection using the :ref:`config_http_conn_man_headers_x-forwarded-for` header. To replace
// this field use a config like the following:
//
// .. code-block:: yaml
//
// original_ip_detection_extensions:
// typed_config:
// "@type": type.googleapis.com/envoy.extensions.http.original_ip_detection.xff.v3.XffConfig
// xff_num_trusted_hops: 1
//
uint32 xff_num_trusted_hops = 19
[deprecated = true, (envoy.annotations.deprecated_at_minor_version) = "3.0"];

// The configuration for the original IP detection extensions.
//
// When configured the extensions will be called along with the request headers
// and information about the downstream connection, such as the directly connected address.
// Each extension will then use these parameters to decide the request's effective remote address.
// If an extension fails to detect the original IP address and isn't configured to reject
// the request, the HCM will try the remaining extensions until one succeeds or rejects
// the request. If the request isn't rejected nor any extension succeeds, the HCM will
// fallback to using the remote address.
//
// [#extension-category: envoy.http.original_ip_detection]
repeated config.core.v3.TypedExtensionConfig original_ip_detection_extensions = 46;

// Configures what network addresses are considered internal for stats and header sanitation
// purposes. If unspecified, only RFC1918 IP addresses will be considered internal.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

api_proto_package(
deps = [
"//envoy/type/v3:pkg",
"@com_github_cncf_udpa//udpa/annotations:pkg",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
syntax = "proto3";

package envoy.extensions.http.original_ip_detection.custom_header.v3;

import "envoy/type/v3/http_status.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.http.original_ip_detection.custom_header.v3";
option java_outer_classname = "CustomHeaderProto";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Custom header original IP detection extension]

// This extension allows for the original downstream remote IP to be detected
// by reading the value from a configured header name. If the value is successfully parsed
// as an IP, it'll be treated as the effective downstream remote address and seen as such
// by all filters. See :ref:`original_ip_detection_extensions
// <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.original_ip_detection_extensions>`
// for an overview of how extensions operate and what happens when an extension fails
// to detect the remote IP.
//
// [#extension: envoy.http.original_ip_detection.custom_header]
message CustomHeaderConfig {
// The header name containing the original downstream remote address, if present.
//
// Note: in the case of a multi-valued header, only the first value is tried and the rest are ignored.
string header_name = 1
[(validate.rules).string = {min_len: 1 well_known_regex: HTTP_HEADER_NAME strict: true}];
rgs1 marked this conversation as resolved.
Show resolved Hide resolved

// If set to true, the extension could decide that the detected address should be treated as
// trusted by the HCM. If the address is considered :ref:`trusted<config_http_conn_man_headers_x-forwarded-for_trusted_client_address>`,
// it might be used as input to determine if the request is internal (among other things).
bool allow_extension_to_set_address_as_trusted = 2;

// If this is set, the request will be rejected when detection fails using it as the HTTP response status.
//
// .. note::
// If this is set to < 400 or > 511, the default status 403 will be used instead.
type.v3.HttpStatus reject_with_status = 3;
}
9 changes: 9 additions & 0 deletions api/envoy/extensions/http/original_ip_detection/xff/v3/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

api_proto_package(
deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"],
)
25 changes: 25 additions & 0 deletions api/envoy/extensions/http/original_ip_detection/xff/v3/xff.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

package envoy.extensions.http.original_ip_detection.xff.v3;

import "udpa/annotations/status.proto";

option java_package = "io.envoyproxy.envoy.extensions.http.original_ip_detection.xff.v3";
option java_outer_classname = "XffProto";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: XFF original IP detection extension]

// This extension allows for the original downstream remote IP to be detected
// by reading the :ref:`config_http_conn_man_headers_x-forwarded-for` header.
//
// [#extension: envoy.http.original_ip_detection.xff]
message XffConfig {
// The number of additional ingress proxy hops from the right side of the
// :ref:`config_http_conn_man_headers_x-forwarded-for` HTTP header to trust when
// determining the origin client's IP address. The default is zero if this option
// is not specified. See the documentation for
// :ref:`config_http_conn_man_headers_x-forwarded-for` for more information.
uint32 xff_num_trusted_hops = 1;
}
2 changes: 2 additions & 0 deletions api/versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ proto_library(
"//envoy/extensions/filters/udp/udp_proxy/v3:pkg",
"//envoy/extensions/health_checkers/redis/v3:pkg",
"//envoy/extensions/http/header_formatters/preserve_case/v3:pkg",
"//envoy/extensions/http/original_ip_detection/custom_header/v3:pkg",
"//envoy/extensions/http/original_ip_detection/xff/v3:pkg",
"//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg",
"//envoy/extensions/internal_redirect/previous_routes/v3:pkg",
"//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg",
Expand Down
1 change: 1 addition & 0 deletions bazel/envoy_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ EXTENSION_CATEGORIES = [
"envoy.http.stateful_header_formatters",
"envoy.internal_redirect_predicates",
"envoy.io_socket",
"envoy.http.original_ip_detection",
"envoy.matching.common_inputs",
"envoy.matching.input_matchers",
"envoy.rate_limit_descriptors",
Expand Down
1 change: 1 addition & 0 deletions docs/root/api-v3/config/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Extensions
descriptors/descriptors
request_id/request_id
http/header_formatters
http/original_ip_detection
8 changes: 8 additions & 0 deletions docs/root/api-v3/config/http/original_ip_detection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Original IP Detection
=====================

.. toctree::
:glob:
:maxdepth: 2

../../extensions/http/original_ip_detection/*/v3/*
11 changes: 8 additions & 3 deletions docs/root/configuration/http/http_conn_man/headers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ Given an HTTP request that has traveled through a series of zero or more proxies
Envoy, the trusted client address is the earliest source IP address that is known to be
accurate. The source IP address of the immediate downstream node's connection to Envoy is
trusted. XFF *sometimes* can be trusted. Malicious clients can forge XFF, but the last
address in XFF can be trusted if it was put there by a trusted proxy.
address in XFF can be trusted if it was put there by a trusted proxy. Alternatively, Envoy
supports :ref:`extensions <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.original_ip_detection_extensions>`
for determining the *trusted client address* or original IP address.

Envoy's default rules for determining the trusted client address (*before* appending anything
to XFF) are:
Expand All @@ -200,8 +202,11 @@ to XFF) are:
node's connection to Envoy.

In an environment where there are one or more trusted proxies in front of an edge
Envoy instance, the *xff_num_trusted_hops* configuration option can be used to trust
additional addresses from XFF:
Envoy instance, the :ref:`XFF extension <envoy_v3_api_msg_extensions.http.original_ip_detection.xff.v3.XffConfig>`
can be configured via the :ref:`original_ip_detection_extensions field
<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.original_ip_detection_extensions>`
to set the *xff_num_trusted_hops* option which controls the number of additional
addresses that are to be trusted:
rgs1 marked this conversation as resolved.
Show resolved Hide resolved

* If *use_remote_address* is false and *xff_num_trusted_hops* is set to a value *N* that is
greater than zero, the trusted client address is the (N+1)th address from the right end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Below are the list of reasons the HttpConnectionManager or Router filter may sen
missing_path_rejected, The request was rejected due to a missing Path or :path header field.
no_healthy_upstream, The request was rejected by the router filter because there was no healthy upstream found.
overload, The request was rejected due to the Overload Manager reaching configured resource limits.
original_ip_detection_failed, The request was rejected because the original IP couldn't be detected.
path_normalization_failed, "The request was rejected because path normalization was configured on and failed, probably due to an invalid path."
request_headers_failed_strict_check, The request was rejected due to x-envoy-* headers failing strict header validation.
request_overall_timeout, The per-stream total request timeout was exceeded.
Expand Down
1 change: 1 addition & 0 deletions docs/root/configuration/http/http_conn_man/stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ statistics:
downstream_rq_http2_total, Counter, Total HTTP/2 requests
downstream_rq_http3_total, Counter, Total HTTP/3 requests
downstream_rq_active, Gauge, Total active requests
downstream_rq_rejected_via_ip_detection, Counter, Total requests rejected because the original IP detection failed
downstream_rq_response_before_rq_complete, Counter, Total responses sent before the request was complete
downstream_rq_rx_reset, Counter, Total request resets received
downstream_rq_tx_reset, Counter, Total request resets sent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ called the *downstream remote address*, for many reasons. Some examples include:
Envoy supports multiple methods for providing the downstream remote address to the upstream host.
These techniques vary in complexity and applicability.

Envoy also supports
:ref:`extensions <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.original_ip_detection_extensions>`
for detecting the original IP address. This might be useful if none of the techniques below is
applicable to your setup. Two available extensions are the :ref:`custom header
<envoy_v3_api_msg_extensions.http.original_ip_detection.custom_header.v3.CustomHeaderConfig>`
extension and the :ref:`xff <envoy_v3_api_msg_extensions.http.original_ip_detection.xff.v3.XffConfig>`
extension.

HTTP Headers
------------

Expand Down
5 changes: 5 additions & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Removed Config or Runtime
New Features
------------

* http: added support for :ref:`original IP detection extensions<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.original_ip_detection_extensions>`.
rgs1 marked this conversation as resolved.
Show resolved Hide resolved
rgs1 marked this conversation as resolved.
Show resolved Hide resolved
Two initial extensions were added, the :ref:`custom header <envoy_v3_api_msg_extensions.http.original_ip_detection.custom_header.v3.CustomHeaderConfig>` extension and the
:ref:`xff <envoy_v3_api_msg_extensions.http.original_ip_detection.xff.v3.XffConfig>` extension.
* http: added the ability to :ref:`unescape slash sequences<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.path_with_escaped_slashes_action>` in the path. Requests with unescaped slashes can be proxied, rejected or redirected to the new unescaped path. By default this feature is disabled. The default behavior can be overridden through :ref:`http_connection_manager.path_with_escaped_slashes_action<config_http_conn_man_runtime_path_with_escaped_slashes_action>` runtime variable. This action can be selectively enabled for a portion of requests by setting the :ref:`http_connection_manager.path_with_escaped_slashes_action_sampling<config_http_conn_man_runtime_path_with_escaped_slashes_action_enabled>` runtime variable.
* http: added upstream and downstream alpha HTTP/3 support! See :ref:`quic_options <envoy_v3_api_field_config.listener.v3.UdpListenerConfig.quic_options>` for downstream and the new http3_protocol_options in :ref:`http_protocol_options <envoy_v3_api_msg_extensions.upstreams.http.v3.HttpProtocolOptions>` for upstream HTTP/3.
* listener: added ability to change an existing listener's address.
Expand All @@ -69,3 +72,5 @@ New Features

Deprecated
----------

* http: :ref:`xff_num_trusted_hops <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.xff_num_trusted_hops>` is deprecated in favor of :ref:`original IP detection extensions<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.original_ip_detection_extensions>`.
2 changes: 2 additions & 0 deletions generated_api_shadow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ proto_library(
"//envoy/extensions/filters/udp/udp_proxy/v3:pkg",
"//envoy/extensions/health_checkers/redis/v3:pkg",
"//envoy/extensions/http/header_formatters/preserve_case/v3:pkg",
"//envoy/extensions/http/original_ip_detection/custom_header/v3:pkg",
"//envoy/extensions/http/original_ip_detection/xff/v3:pkg",
"//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg",
"//envoy/extensions/internal_redirect/previous_routes/v3:pkg",
"//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg",
Expand Down
Loading