Serve TestGen Through a Reverse Proxy¶
Use a reverse proxy to serve the TestGen UI, the REST API, and the MCP server on one HTTPS address on the standard port 443, such as https://testgen.example.com, instead of on ports 8501 and 8530. One address on port 443 is simpler to share, passes through networks that allow only standard HTTPS, and is required by hosted clients that connect only on that port, such as custom connectors in Claude.ai.
To keep serving the UI and the API on their own ports, over HTTPS, see Configure HTTPS instead. On Kubernetes, configure the chart's ingress as in Install on Kubernetes instead of setting up NGINX.
Set up an NGINX reverse proxy¶
The steps use NGINX in a container next to TestGen. The proxy holds the certificate, and TestGen serves plain HTTP on the Docker network.
These steps require the following.
- TestGen instance installed using dk-installer.exe, as outlined in Install on Windows, or dk-installer, as outlined in Install on Mac/Linux or Install Enterprise.
-
An SSL certificate file and its private key file, in PEM format, for the domain used to access TestGen.
-
Navigate to the directory that contains the
docker-compose.ymlfile for TestGen.- If the instance was installed using dk-installer.exe, the file can be located under "AppData\Local\DataKitchenApps".
- If the instance was installed using dk-installer, the file can be located in the folder from which the Python installer was executed.
-
Copy the certificate and key into the directory as
domain.crtanddomain.key. -
Create an
nginx.conffile in the directory with the following contents. Replace<host>with the host name on your certificate.events {} http { server_tokens off; server { listen 443 ssl; server_name <host>; ssl_certificate /etc/ssl/domain.crt; ssl_certificate_key /etc/ssl/domain.key; ssl_protocols TLSv1.2 TLSv1.3; # API and MCP server location ~ ^/(mcp(/|$)|api/|oauth/|\.well-known/) { proxy_pass http://engine:8530; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_http_version 1.1; proxy_buffering off; proxy_read_timeout 3600s; client_max_body_size 10m; } # UI location / { proxy_pass http://engine:8501; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; } } server { listen 80; return 301 https://$host$request_uri; } }Keep
proxy_buffering offand the longproxy_read_timeoutvalues: MCP streams its responses, and the UI holds a WebSocket connection open. If you setTG_API_MAX_REQUEST_BODY_BYTES, setclient_max_body_sizeto match. -
In
docker-compose.yml, add an nginx service, with the samenetworksas the engine service. -
In the engine service, remove the
portssection so that all traffic goes through the proxy. If the service mounts a certificate as in Configure HTTPS, remove those bind mounts as well. -
Set the following variables under the x-common-variables section. Use the host name on your certificate, without a port. If
SSL_CERT_FILEandSSL_KEY_FILEare set, remove them. -
Restart the application.
-
Open port 443 in the firewall or security group of the TestGen server. Ports 8501 and 8530 do not need to be open.
Note
AI clients and integrations configured with a URL on port 8530 stop connecting. Update them to https://<host>/mcp for MCP, or https://<host>/api/v1 for the REST API.
Use your own reverse proxy¶
To serve TestGen through a reverse proxy or load balancer that you already run, configure it to send requests whose path starts with one of the following prefixes to the REST API and MCP port (8530), and all other requests to the UI port (8501).
| Path prefix | Serves |
|---|---|
/api/ |
REST API and its reference documentation |
/mcp |
MCP server |
/oauth/ |
OAuth sign-in and token endpoints |
/.well-known/ |
OAuth discovery metadata |
The proxy must also:
- Pass the
Hostheader through unchanged. If the proxy rewrites it, add the host name it sends to theTG_MCP_EXTRA_ALLOWED_HOSTSenvironment variable. - Turn off response buffering for
/mcp. - Accept request bodies of up to 10 MB on the REST API and MCP paths, or up to
TG_API_MAX_REQUEST_BODY_BYTESif you set it. - Allow WebSocket connections to the UI, and keep idle connections open for at least 90 seconds.
- If the proxy or a CDN caches responses, include the query string in the cache key.
If the proxy or load balancer checks health, use /_stcore/health for the UI and /api/v1/health for the REST API and MCP server.
Then set TG_UI_BASE_URL and TG_BASE_URL to https://<host>. See Set Environment Variables.
Serve TestGen under a path¶
To share a host with other applications, serve TestGen under a path, such as https://<host>/testgen. These steps apply to any reverse proxy or load balancer, however TestGen is installed.
- Set
TG_UI_BASE_URLandTG_BASE_URLtohttps://<host>/testgen. TestGen serves the UI, the REST API, and the MCP server under that path. See Set Environment Variables. - Configure the proxy or load balancer to forward the following requests without removing the path. It must also meet the requirements in Use your own reverse proxy.
- Send
/testgen/api/,/testgen/mcp,/testgen/oauth/,/.well-known/oauth-authorization-server/testgen, and/.well-known/oauth-protected-resource/testgen/mcpto the API and MCP port (8530). The two/.well-known/paths are at the root of the host, not under/testgen. - Send all other requests under
/testgento the UI port (8501). - Redirect
/testgento/testgen/, keeping the query string.
- Send
- If the proxy or load balancer checks health, use
/testgen/_stcore/healthfor the UI and/testgen/api/v1/healthfor the API and MCP server. - Enterprise If you use single sign-on, set the redirect URI in your identity provider and
redirect_uriinsso_auth.tomltohttps://<host>/testgen/, including the path and its trailing slash. See Configure Single Sign-On. - Configure AI clients and integrations with
https://<host>/testgen/mcpfor MCP, orhttps://<host>/testgen/api/v1for the REST API.
To use different paths for the UI and the API, such as https://<host>/testgen for TG_UI_BASE_URL and https://<host>/testgen-api for TG_BASE_URL, send all requests under the API path to port 8530, and use the API path in the two /.well-known/ paths, such as /.well-known/oauth-protected-resource/testgen-api/mcp.
Related topics¶
- Set up the MCP Server — connect AI clients to the MCP server
- Access TestGen from Another Machine — reach TestGen from other machines on your network