Skip to content

Using Cloud Foundry Behind the STACKIT Application Load Balancer (ALB)

Last updated on

Cloud Foundry (CF) can be placed behind the STACKIT Application Load Balancer (ALB). This setup routes all incoming CF traffic through the ALB first, giving you custom SSL/TLS certificates, ALB WAF protection, and Access Control Lists (ACLs) in a single, centralized layer.

Instead of sending traffic directly to your Cloud Foundry Load Balancer, place the ALB in front of it:

[Client] -> [STACKIT ALB (Cert + ALB WAF + ACL)] -> [Cloud Foundry LB] -> [CF Apps]

The ALB supports routing traffic to arbitrary IP addresses in its target pool. When creating the ALB, set disableTargetSecurityGroupAssignment to true so the ALB does not manage target security groups automatically and allows you to register the IP address of your existing Cloud Foundry Load Balancer as a target. Because this option cannot be toggled after creation, an existing ALB must be recreated to change it. Once DNS points to the ALB, all traffic flows through your ALB WAF and ACL rules before reaching Cloud Foundry.

Because the ALB acts as a reverse proxy in front of Cloud Foundry, keep these technical details in mind:

  • Listener Path Matching (Prefix vs. Exact): Configure the ALB listener rule with Prefix matching on / rather than Exact matching. Leaving the rule on Exact for / matches only the root path and causes all other paths and static assets (such as JavaScript and CSS files) to return 404 errors.
  • Bypass Risk on Shared Cloud Foundry: On Shared Cloud Foundry, the Cloud Foundry ingress IP is publicly reachable and cannot be restricted by customers via an allowlist to accept traffic only from the ALB. Clients can therefore bypass the ALB—along with its ALB WAF and ACLs—by sending requests directly to the Cloud Foundry ingress. If strict enforcement is required, verify within your application that incoming traffic originated from the ALB (for example, by checking the ALB’s IP address as the last-seen IP).
  • Trusted Client IP (STACKIT-CF-Trusted-IP): The Cloud Foundry Load Balancer sets the STACKIT-CF-Trusted-IP header to the last-seen IP address of the incoming connection. When traffic is routed through the ALB, this header contains the ALB egress IP address; otherwise, it contains the client’s IP address or a web proxy IP address.
  • Original Client IP (X-Forwarded-For): The ALB automatically adds the X-Forwarded-For and X-Forwarded-Proto headers to forwarded requests and ignores any existing values on incoming client requests to prevent spoofing. Applications that need the connecting client’s IP can read it from X-Forwarded-For. However, if traffic passes through an upstream proxy before reaching the ALB, X-Forwarded-For reflects that proxy’s IP address rather than the original client IP behind it.