Skip to content
AI GatewayAI Gateway Manual

Load Balancer

Configure an AWS ALB to terminate TLS in front of AI Gateway, including listener, target group, health check, idle timeout, and security group rules.

AI Gateway does not terminate TLS. The web container speaks plain HTTP on AIG_HTTP_PORT (default 80), and a TLS-terminating load balancer sits in front of the host. Users and the IdP reach the gateway over HTTPS at the load balancer’s address; the load balancer forwards plain HTTP to AIG_HTTP_PORT on the host.

Accessing the gateway directly over http:// from a browser is not supported, except in a localhost evaluation install (--hostname localhost). In any other deployment the backend starts with an HTTPS base URL, and browsers block login cookies (marked Secure) and certain browser APIs over plain HTTP. The IdP and the MCP authorization server also require an HTTPS redirect URI.

See Getting Started for prerequisites, the port variables, and the localhost install mode.

VariableDefaultMeaning
AIG_HTTP_PORT80Host port that the web container exposes. The load balancer’s target group points here.
AIG_PUBLIC_PORT443HTTPS port that users reach at the load balancer. Used to build MANAGEMENT_BASE_URL when the port is not 443.

AIG_HTTP_PORT is the only port opened on the host by Docker. The load balancer delivers traffic to this port and nothing else should reach it from outside the load balancer’s security group.

SettingValue
ListenerHTTPS on port 443 (or AIG_PUBLIC_PORT). Attach the customer certificate from ACM. Point the DNS hostname at the ALB.
Target group protocolHTTP
Target group portAIG_HTTP_PORT (default 80)
Health checkHTTP GET /readyz, expected response code 200
X-Forwarded-For handlingLeave at the default append. Do not change to preserve or remove (see Client IP).
Idle timeoutRaise above the default 60 seconds. Long non-streaming LLM responses and quiet MCP connections can exceed 60 seconds; a timeout mid-response returns an error to the user. A value of 300 to 600 seconds is a reasonable starting point; tune it to the slowest model response you need to support.
Security groupRestrict inbound access on AIG_HTTP_PORT to the ALB’s security group only. Direct access bypasses TLS and allows clients to send arbitrary X-Forwarded-For values.

The health check path /readyz is served by the server container through web. It returns HTTP 200 when server is up and its dependencies are reachable. The web container has its own internal health check on /healthz (port 8081 inside the container), but the ALB target group should use /readyz because it verifies the full stack.

To test from the host:

Terminal window
curl -sf http://127.0.0.1/readyz && echo ok
# If AIG_HTTP_PORT is not 80 (substitute the port you chose):
curl -sf http://127.0.0.1:8080/readyz && echo ok

web sends X-Content-Type-Options: nosniff on every response.

Strict-Transport-Security (HSTS) is intentionally not sent. Browsers remember HSTS for a year; if a certificate problem arises, users cannot bypass the error, and other HTTP services on the same hostname are also forced to HTTPS. If your security policy requires HSTS, add it at the load balancer.

The backend uses the last value of the X-Forwarded-For header as the client IP. It writes this value to audit logs, applies project IP policies, and enforces unauthenticated request limits against it.

When X-Forwarded-For handling is set to append (the ALB default), the ALB appends the address of the connecting client to any existing header values. The web container passes the header to server unchanged. A user on a private network therefore appears with their real private address, and any value the client itself sent is placed earlier in the list where it is not used.

If a request arrives at web with no X-Forwarded-For header (because it bypassed the load balancer), web fills it with the address of the connecting TCP peer. On hosts with Docker’s userland proxy enabled, that peer address may be the Docker bridge gateway rather than the actual client address.

A client that bypasses the load balancer can send any X-Forwarded-For value and have it used as the last entry. Restricting AIG_HTTP_PORT to the ALB’s security group prevents this.

If the load balancer listens on a port other than 443, set AIG_PUBLIC_PORT before the first install so the base URL is built correctly:

Terminal window
AIG_PUBLIC_PORT=8443 ./install.sh install --hostname aig.example.com

If web should listen on a host port other than 80, set AIG_HTTP_PORT:

Terminal window
AIG_HTTP_PORT=8080 ./install.sh install --hostname aig.example.com

Both variables are applied only when .env is created. To change them on a running installation, edit .env directly and recreate the affected containers:

Terminal window
cd aig/current
docker compose up -d

With Okta SCIM provisioning, Okta sends requests to the gateway’s /scim/v2. Unlike other paths, these requests come from the Okta cloud, so a gateway that is reachable only from your network needs one of the options below. For the setup, see SCIM provisioning on the Okta user provisioning page.

OptionConfiguration
Expose only /scim/v2 to the internetOn an internet-facing ALB (or a public listener on the existing ALB), add a rule that forwards only the path /scim/v2/* to the target group, and leave the default rule as a fixed 404 response. If your security policy calls for it, restrict the source IPs to the IP ranges Okta publishes (Okta: Allow access to Okta IP addresses).
Okta Provisioning AgentIf inbound access cannot be opened, install the Okta Provisioning Agent on a host inside your network. The agent only makes outbound connections to Okta and forwards the requests it receives to /scim/v2 at the internal address. To install it, follow Okta: Install the Okta Provisioning Agent.

To check that requests reach the gateway, call it without a token. A 401 means the request reached the gateway. If the console’s HTML comes back, the installed version predates this path; upgrade.

Terminal window
curl -s -o /dev/null -w '%{http_code}\n' https://aig.example.com/scim/v2/Users