XffHeaderProcessingMode Enum
Processing mode of the X-Forwarded-For header in the HTTP request before the Application Load Balancer sends the request to the target.
Example
ts
declare const vpc: ec2.Vpc;
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: true,
// Whether HTTP/2 is enabled
http2Enabled: false,
// The idle timeout value, in seconds
idleTimeout: Duration.seconds(1000),
// Whether HTTP headers with header fields that are not valid
// are removed by the load balancer (true), or routed to targets
dropInvalidHeaderFields: true,
// How the load balancer handles requests that might
// pose a security risk to your application
desyncMitigationMode: elbv2.DesyncMitigationMode.DEFENSIVE,
// The type of IP addresses to use.
ipAddressType: elbv2.IpAddressType.IPV4,
// The duration of client keep-alive connections
clientKeepAlive: Duration.seconds(500),
// Whether cross-zone load balancing is enabled.
crossZoneEnabled: true,
// Whether the load balancer blocks traffic through the Internet Gateway (IGW).
denyAllIgwTraffic: false,
// Whether to preserve host header in the request to the target
preserveHostHeader: true,
// Whether to add the TLS information header to the request
xAmznTlsVersionAndCipherSuiteHeaders: true,
// Whether the X-Forwarded-For header should preserve the source port
preserveXffClientPort: true,
// The processing mode for X-Forwarded-For headers
xffHeaderProcessingMode: elbv2.XffHeaderProcessingMode.APPEND,
// Whether to allow a load balancer to route requests to targets if it is unable to forward the request to AWS WAF.
wafFailOpen: true,
});
python
# vpc: ec2.Vpc
lb = elbv2.ApplicationLoadBalancer(self, "LB",
vpc=vpc,
internet_facing=True,
# Whether HTTP/2 is enabled
http2_enabled=False,
# The idle timeout value, in seconds
idle_timeout=Duration.seconds(1000),
# Whether HTTP headers with header fields that are not valid
# are removed by the load balancer (true), or routed to targets
drop_invalid_header_fields=True,
# How the load balancer handles requests that might
# pose a security risk to your application
desync_mitigation_mode=elbv2.DesyncMitigationMode.DEFENSIVE,
# The type of IP addresses to use.
ip_address_type=elbv2.IpAddressType.IPV4,
# The duration of client keep-alive connections
client_keep_alive=Duration.seconds(500),
# Whether cross-zone load balancing is enabled.
cross_zone_enabled=True,
# Whether the load balancer blocks traffic through the Internet Gateway (IGW).
deny_all_igw_traffic=False,
# Whether to preserve host header in the request to the target
preserve_host_header=True,
# Whether to add the TLS information header to the request
x_amzn_tls_version_and_cipher_suite_headers=True,
# Whether the X-Forwarded-For header should preserve the source port
preserve_xff_client_port=True,
# The processing mode for X-Forwarded-For headers
xff_header_processing_mode=elbv2.XffHeaderProcessingMode.APPEND,
# Whether to allow a load balancer to route requests to targets if it is unable to forward the request to AWS WAF.
waf_fail_open=True
)
java
Vpc vpc;
ApplicationLoadBalancer lb = ApplicationLoadBalancer.Builder.create(this, "LB")
.vpc(vpc)
.internetFacing(true)
// Whether HTTP/2 is enabled
.http2Enabled(false)
// The idle timeout value, in seconds
.idleTimeout(Duration.seconds(1000))
// Whether HTTP headers with header fields that are not valid
// are removed by the load balancer (true), or routed to targets
.dropInvalidHeaderFields(true)
// How the load balancer handles requests that might
// pose a security risk to your application
.desyncMitigationMode(DesyncMitigationMode.DEFENSIVE)
// The type of IP addresses to use.
.ipAddressType(IpAddressType.IPV4)
// The duration of client keep-alive connections
.clientKeepAlive(Duration.seconds(500))
// Whether cross-zone load balancing is enabled.
.crossZoneEnabled(true)
// Whether the load balancer blocks traffic through the Internet Gateway (IGW).
.denyAllIgwTraffic(false)
// Whether to preserve host header in the request to the target
.preserveHostHeader(true)
// Whether to add the TLS information header to the request
.xAmznTlsVersionAndCipherSuiteHeaders(true)
// Whether the X-Forwarded-For header should preserve the source port
.preserveXffClientPort(true)
// The processing mode for X-Forwarded-For headers
.xffHeaderProcessingMode(XffHeaderProcessingMode.APPEND)
// Whether to allow a load balancer to route requests to targets if it is unable to forward the request to AWS WAF.
.wafFailOpen(true)
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;
var lb = new ApplicationLoadBalancer(this, "LB", new ApplicationLoadBalancerProps {
Vpc = vpc,
InternetFacing = true,
// Whether HTTP/2 is enabled
Http2Enabled = false,
// The idle timeout value, in seconds
IdleTimeout = Duration.Seconds(1000),
// Whether HTTP headers with header fields that are not valid
// are removed by the load balancer (true), or routed to targets
DropInvalidHeaderFields = true,
// How the load balancer handles requests that might
// pose a security risk to your application
DesyncMitigationMode = DesyncMitigationMode.DEFENSIVE,
// The type of IP addresses to use.
IpAddressType = IpAddressType.IPV4,
// The duration of client keep-alive connections
ClientKeepAlive = Duration.Seconds(500),
// Whether cross-zone load balancing is enabled.
CrossZoneEnabled = true,
// Whether the load balancer blocks traffic through the Internet Gateway (IGW).
DenyAllIgwTraffic = false,
// Whether to preserve host header in the request to the target
PreserveHostHeader = true,
// Whether to add the TLS information header to the request
XAmznTlsVersionAndCipherSuiteHeaders = true,
// Whether the X-Forwarded-For header should preserve the source port
PreserveXffClientPort = true,
// The processing mode for X-Forwarded-For headers
XffHeaderProcessingMode = XffHeaderProcessingMode.APPEND,
// Whether to allow a load balancer to route requests to targets if it is unable to forward the request to AWS WAF.
WafFailOpen = true
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc
lb := elbv2.NewApplicationLoadBalancer(this, jsii.String("LB"), &ApplicationLoadBalancerProps{
Vpc: Vpc,
InternetFacing: jsii.Boolean(true),
// Whether HTTP/2 is enabled
Http2Enabled: jsii.Boolean(false),
// The idle timeout value, in seconds
IdleTimeout: awscdk.Duration_Seconds(jsii.Number(1000)),
// Whether HTTP headers with header fields that are not valid
// are removed by the load balancer (true), or routed to targets
DropInvalidHeaderFields: jsii.Boolean(true),
// How the load balancer handles requests that might
// pose a security risk to your application
DesyncMitigationMode: elbv2.DesyncMitigationMode_DEFENSIVE,
// The type of IP addresses to use.
IpAddressType: elbv2.IpAddressType_IPV4,
// The duration of client keep-alive connections
ClientKeepAlive: awscdk.Duration_*Seconds(jsii.Number(500)),
// Whether cross-zone load balancing is enabled.
CrossZoneEnabled: jsii.Boolean(true),
// Whether the load balancer blocks traffic through the Internet Gateway (IGW).
DenyAllIgwTraffic: jsii.Boolean(false),
// Whether to preserve host header in the request to the target
PreserveHostHeader: jsii.Boolean(true),
// Whether to add the TLS information header to the request
XAmznTlsVersionAndCipherSuiteHeaders: jsii.Boolean(true),
// Whether the X-Forwarded-For header should preserve the source port
PreserveXffClientPort: jsii.Boolean(true),
// The processing mode for X-Forwarded-For headers
XffHeaderProcessingMode: elbv2.XffHeaderProcessingMode_APPEND,
// Whether to allow a load balancer to route requests to targets if it is unable to forward the request to AWS WAF.
WafFailOpen: jsii.Boolean(true),
})
Members
| Member | Description |
|---|---|
APPEND | Application Load Balancer adds the client IP address (of the last hop) to the X-Forwarded-For header in the HTTP request before it sends it to targets. |
PRESERVE | Application Load Balancer preserves the X-Forwarded-For header in the HTTP request, and sends it to targets without any change. |
REMOVE | Application Load Balancer removes the X-Forwarded-For header in the HTTP request before it sends it to targets. |
Referenced by
ApplicationLoadBalancerProps.xffHeaderProcessingModexff_header_processing_modexffHeaderProcessingModeXffHeaderProcessingModeXffHeaderProcessingMode