Configure an L7 load balancer
What you’ll accomplish
Section titled “What you’ll accomplish”After completing this guide, UDS Core will work correctly behind an L7 load balancer such as AWS Application Load Balancer (ALB) or Azure Application Gateway. This involves configuring external TLS termination, trusted proxy settings, and optionally client certificate forwarding.
Prerequisites
Section titled “Prerequisites”- UDS CLI installed
- Access to a Kubernetes cluster with prerequisites met
- An L7 load balancer (AWS ALB, Azure Application Gateway, or similar) provisioned
Before you begin
Section titled “Before you begin”-
Configure your UDS Bundle with L7 overrides
Add the necessary overrides to your UDS Core bundle configuration. This disables HTTPS redirects (since the L7 load balancer terminates TLS before traffic reaches Istio) and sets the trusted proxy count:
uds-bundle.yaml kind: UDSBundlemetadata:name: my-uds-coredescription: UDS Core behind an L7 load balancerversion: "0.1.0"packages:- name: corerepository: registry.defenseunicorns.com/public/coreref: x.x.x-upstreamoverrides:istio-tenant-gateway:uds-istio-config:values:- path: tls.servers.keycloak.enableHttpsRedirectvalue: false- path: tls.servers.tenant.enableHttpsRedirectvalue: false# Uncomment if admin gateway is also behind the L7 load balancer:# istio-admin-gateway:# uds-istio-config:# values:# - path: tls.servers.keycloak.enableHttpsRedirect# value: false# - path: tls.servers.admin.enableHttpsRedirect# value: falseistio-controlplane:istiod:values:# Set to the number of proxies in front of Istio (e.g., 1 for a single ALB)- path: meshConfig.defaultConfig.gatewayTopology.numTrustedProxiesvalue: 1 -
Configure client certificate forwarding (if using mTLS)
If your L7 load balancer performs mutual TLS and forwards client certificates to Keycloak (e.g., for DoD CAC authentication), configure Keycloak to read the certificate from the correct header:
uds-bundle.yaml overrides:keycloak:keycloak:values:- path: thirdPartyIntegration.tls.tlsCertificateHeader# AWS ALB uses this header for client certificatesvalue: "x-amzn-mtls-clientcert"- path: thirdPartyIntegration.tls.tlsCertificateFormat# "AWS" for ALB, "PEM" for load balancers that forward standard PEMvalue: "AWS" -
Create and deploy your bundle
Terminal window uds create --confirm && uds deploy uds-bundle-*.tar.zst --confirm -
Route the load balancer to the Istio gateway
Configure your L7 load balancer to forward traffic to the Istio ingress gateway service. The exact steps vary by cloud provider and infrastructure setup:
- AWS ALB: Create a target group pointing at the Network Load Balancer (NLB) or NodePort provisioned by the
tenant-ingressgatewayservice inistio-tenant-gateway, then attach that target group to the ALB listener. - Azure Application Gateway: Configure a backend pool targeting the Istio gateway service’s external IP or node ports.
Verify the gateway service is available:
Terminal window uds zarf tools kubectl get svc -n istio-tenant-gateway tenant-ingressgatewayThe
EXTERNAL-IPorPORT(S)shown will be the target for your load balancer’s backend configuration. - AWS ALB: Create a target group pointing at the Network Load Balancer (NLB) or NodePort provisioned by the
Verification
Section titled “Verification”- Access an application through the load balancer URL and confirm it loads without redirect loops
- Verify Keycloak SSO works end-to-end by logging in through the tenant gateway
- If using mTLS, verify client certificate-based authentication works through Keycloak
Troubleshooting
Section titled “Troubleshooting”Redirect loop
Section titled “Redirect loop”Symptoms: Browser shows “too many redirects” or ERR_TOO_MANY_REDIRECTS.
Solution: Verify that HTTPS redirects are disabled for all gateway servers behind the load balancer. For the tenant gateway, both tls.servers.keycloak.enableHttpsRedirect and tls.servers.tenant.enableHttpsRedirect must be set to false. For the admin gateway, use tls.servers.keycloak.enableHttpsRedirect and tls.servers.admin.enableHttpsRedirect. If the admin gateway is also behind the L7 load balancer, disable redirects there too.
Incorrect client IP or forwarded headers
Section titled “Incorrect client IP or forwarded headers”Symptoms: Applications see the load balancer’s IP instead of the client’s IP; rate limiting or IP-based access control doesn’t work correctly.
Solution: Verify numTrustedProxies is set to the correct number of proxy hops between the client and Istio. If too low, Istio doesn’t trust the X-Forwarded-For header; if too high, clients could spoof their IP.
Keycloak mTLS not working
Section titled “Keycloak mTLS not working”Symptoms: Client certificate authentication fails through the load balancer but works when connecting directly to Istio.
Solution:
- Verify the
tlsCertificateHeadermatches the header your load balancer uses to forward the certificate - Verify the
tlsCertificateFormatmatches your load balancer’s format (AWSfor ALB,PEMfor others) - Ensure the load balancer is configured to forward client certificates
Related documentation
Section titled “Related documentation”Next steps
Section titled “Next steps”These guides and concepts may be useful to explore next: