Skip to content

http: Support inferring X-Forwarded-Proto from PROXY protocol destination port#43088

Merged
yanavlasov merged 9 commits intoenvoyproxy:mainfrom
prashanthjos:x-forwarded-proto
Jan 29, 2026
Merged

http: Support inferring X-Forwarded-Proto from PROXY protocol destination port#43088
yanavlasov merged 9 commits intoenvoyproxy:mainfrom
prashanthjos:x-forwarded-proto

Conversation

@prashanthjos
Copy link
Copy Markdown
Contributor

@prashanthjos prashanthjos commented Jan 21, 2026

Commit Message: http: add support for inferring x-forwarded-proto from PROXY protocol destination port

Additional Description:

When using Layer 4 load balancers (like AWS NLB) that terminate TLS and forward traffic using PROXY protocol, Envoy receives unencrypted traffic but needs to know the original protocol for correct redirect behavior.

This change adds a new HCM configuration option forwarded_proto_config that allows specifying which PROXY protocol destination ports should be treated as HTTPS or HTTP. When enabled and the local address was restored from PROXY protocol, the x-forwarded-proto header is set based on whether the destination port is in https_destination_ports or http_destination_ports.

Example configuration:

http_connection_manager:
  forwarded_proto_config:
    https_destination_ports: [443, 8443]
    http_destination_ports: [80, 8080]

Risk Level: Low - opt-in feature that only activates when explicitly configured and when localAddressRestored() is true
Testing: Added 6 unit tests in conn_manager_utility_test.cc covering port 443/80 mapping, unmapped ports, empty config, non-restored address, and custom ports
Docs Changes: N/A
Release Notes: Added
Platform Specific Features:
[Optional Runtime guard:]
Fixes #43031
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
API Considerations: Added new message ForwardedProtoConfig and field forwarded_proto_config (#61) to HttpConnectionManager. The configuration uses two repeated uint32 fields (https_destination_ports and http_destination_ports) for type-safe port specification without requiring string validation.

… destination port

When using Layer 4 load balancers (like AWS NLB) that terminate TLS and forward traffic using PROXY protocol, Envoy receives unencrypted traffic but needs to know the original protocol for correct redirect behavior.

This change adds a new HCM configuration option `set_forwarded_proto_from_proxy_protocol_destination_port` that allows mapping PROXY protocol destination ports to schemes (e.g., 443 -> https,
80 -> http). When enabled and the local address was restored from PROXY
protocol, the x-forwarded-proto header is set based on the configured port-to-scheme mapping.

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
… destination port

When using Layer 4 load balancers (like AWS NLB) that terminate TLS and forward traffic using PROXY protocol, Envoy receives unencrypted traffic but needs to know the original protocol for correct redirect behavior.

This change adds a new HCM configuration option `set_forwarded_proto_from_proxy_protocol_destination_port` that allows mapping PROXY protocol destination ports to schemes (e.g., 443 -> https, 80 -> http). When enabled and the local address was restored from PROXY protocol, the x-forwarded-proto header is set based on the configured port-to-scheme mapping.

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
… destination port

When using Layer 4 load balancers (like AWS NLB) that terminate TLS and forward traffic using PROXY protocol, Envoy receives unencrypted traffic but needs to know the original protocol for correct redirect behavior.

This change adds a new HCM configuration option `set_forwarded_proto_from_proxy_protocol_destination_port` that allows mapping PROXY protocol destination ports to schemes (e.g., 443 -> https, 80 -> http). When enabled and the local address was restored from PROXY protocol, the x-forwarded-proto header is set based on the configured port-to-scheme mapping.

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @wbpcode
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #43088 was opened by prashanthjos.

see: more, trace.

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
@prashanthjos
Copy link
Copy Markdown
Contributor Author

@mattklein123 and @yanavlasov can you please take a look at this PR

@yanavlasov yanavlasov self-assigned this Jan 22, 2026
Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. Some comments to API first.

// Configuration for setting x-forwarded-proto based on PROXY protocol destination port.
// This enables Envoy to infer the original protocol (HTTP/HTTPS) when behind an L4 load
// balancer that terminates TLS and uses PROXY protocol.
message SetForwardedProtoFromProxyProtocolDestinationPort {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForwardedProtoOptions or ForwardedProtoConfig. We may could support other more flexible solution in the future.

//
// The scheme values must be either "http" or "https".
// Invalid scheme values will be rejected during configuration loading.
map<uint32, string> port_scheme_mappings = 1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather then a string, maybe https_destination_ports and http_destination_ports with type repeated uint32 be better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done changed!

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
@prashanthjos
Copy link
Copy Markdown
Contributor Author

/retest

@prashanthjos
Copy link
Copy Markdown
Contributor Author

@wbpcode I have addressed your comments can you please take a look

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall with one last comment. Thanks for the update.

//
// If not configured, defaults to disabled and the standard behavior applies (using connection
// TLS status or trusted downstream headers).
ForwardedProtoConfig forwarded_proto_config = 61;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the regression. May name the API to ForwardProtoConfig, to keep same style with exsiting ForwardClientCertConfig.

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
@prashanthjos
Copy link
Copy Markdown
Contributor Author

/retest

@prashanthjos
Copy link
Copy Markdown
Contributor Author

@wbpcode addressed your comments !

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Jan 28, 2026

Hello, @yanavlasov, i see you assign this to yourself? is there any additional concern from you?

@yanavlasov yanavlasov merged commit f126920 into envoyproxy:main Jan 29, 2026
26 checks passed
shane-yuan pushed a commit to shane-yuan/envoy that referenced this pull request Feb 11, 2026
…tion port (envoyproxy#43088)

When using Layer 4 load balancers (like AWS NLB) that terminate TLS and
forward traffic using PROXY protocol, Envoy receives unencrypted traffic
but needs to know the original protocol for correct redirect behavior.

This change adds a new HCM configuration option `forwarded_proto_config`
that allows specifying which PROXY protocol destination ports should be
treated as HTTPS or HTTP. When enabled and the local address was
restored from PROXY protocol, the `x-forwarded-proto` header is set
based on whether the destination port is in `https_destination_ports` or
`http_destination_ports`.

Example configuration:

```
http_connection_manager:
  forwarded_proto_config:
    https_destination_ports: [443, 8443]
    http_destination_ports: [80, 8080]
```

Risk Level: Low - opt-in feature that only activates when explicitly
configured and when localAddressRestored() is true
Testing: Added 6 unit tests in conn_manager_utility_test.cc covering
port 443/80 mapping, unmapped ports, empty config, non-restored address,
and custom ports
Docs Changes: N/A
Release Notes: Added
Platform Specific Features:
[Optional Runtime guard:]
 Fixes envoyproxy#43031 
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
API Considerations: Added new message ForwardedProtoConfig and field
forwarded_proto_config (envoyproxy#61) to HttpConnectionManager. The configuration
uses two repeated uint32 fields (https_destination_ports and
http_destination_ports) for type-safe port specification without
requiring string validation.

---------

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
grnmeira pushed a commit to grnmeira/envoy that referenced this pull request Mar 20, 2026
…tion port (envoyproxy#43088)

When using Layer 4 load balancers (like AWS NLB) that terminate TLS and
forward traffic using PROXY protocol, Envoy receives unencrypted traffic
but needs to know the original protocol for correct redirect behavior.

This change adds a new HCM configuration option `forwarded_proto_config`
that allows specifying which PROXY protocol destination ports should be
treated as HTTPS or HTTP. When enabled and the local address was
restored from PROXY protocol, the `x-forwarded-proto` header is set
based on whether the destination port is in `https_destination_ports` or
`http_destination_ports`.

Example configuration:

```
http_connection_manager:
  forwarded_proto_config:
    https_destination_ports: [443, 8443]
    http_destination_ports: [80, 8080]
```

Risk Level: Low - opt-in feature that only activates when explicitly
configured and when localAddressRestored() is true
Testing: Added 6 unit tests in conn_manager_utility_test.cc covering
port 443/80 mapping, unmapped ports, empty config, non-restored address,
and custom ports
Docs Changes: N/A
Release Notes: Added
Platform Specific Features:
[Optional Runtime guard:]
 Fixes envoyproxy#43031
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
API Considerations: Added new message ForwardedProtoConfig and field
forwarded_proto_config (envoyproxy#61) to HttpConnectionManager. The configuration
uses two repeated uint32 fields (https_destination_ports and
http_destination_ports) for type-safe port specification without
requiring string validation.

---------

Signed-off-by: Prashanth Josyula <prashanth.16@gmail.com>
Signed-off-by: Gustavo <grnmeira@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support inferring X-Forwarded-Proto from PROXY Protocol destination port

3 participants