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.
Port relationship
Section titled “Port relationship”| Variable | Default | Meaning |
|---|---|---|
AIG_HTTP_PORT | 80 | Host port that the web container exposes. The load balancer’s target group points here. |
AIG_PUBLIC_PORT | 443 | HTTPS 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.
AWS ALB configuration
Section titled “AWS ALB configuration”| Setting | Value |
|---|---|
| Listener | HTTPS on port 443 (or AIG_PUBLIC_PORT). Attach the customer certificate from ACM. Point the DNS hostname at the ALB. |
| Target group protocol | HTTP |
| Target group port | AIG_HTTP_PORT (default 80) |
| Health check | HTTP GET /readyz, expected response code 200 |
X-Forwarded-For handling | Leave at the default append. Do not change to preserve or remove (see Client IP). |
| Idle timeout | Raise 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 group | Restrict 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. |
Health check detail
Section titled “Health check detail”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:
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 okResponse headers
Section titled “Response headers”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.
Client IP
Section titled “Client IP”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.
Non-standard ports
Section titled “Non-standard ports”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:
AIG_PUBLIC_PORT=8443 ./install.sh install --hostname aig.example.comIf web should listen on a host port other than 80, set AIG_HTTP_PORT:
AIG_HTTP_PORT=8080 ./install.sh install --hostname aig.example.comBoth variables are applied only when .env is created. To change them on a
running installation, edit .env directly and recreate the affected containers:
cd aig/currentdocker compose up -dSCIM path
Section titled “SCIM path”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.
| Option | Configuration |
|---|---|
Expose only /scim/v2 to the internet | On 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 Agent | If 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.
curl -s -o /dev/null -w '%{http_code}\n' https://aig.example.com/scim/v2/Users