Skip to content

Test over HTTPS on a local domain

Verified against gamewarden v0.1.0 (see the changelog). About 10 minutes.

The compose stack serves the gateway over HTTPS at https://gamewarden.test, with a self-signed certificate. Use it when you want to test what a real deployment does: an agent or MCP client that only accepts https:// URLs, cookies marked Secure, or a browser that refuses mixed content. This page shows how to point the domain at your machine, copy the certificate out of Docker, trust it, and reach the gateway from your host and from other containers.

.test is reserved for testing (RFC 2606), so the name can never belong to a real site.

docker compose up starts two services next to the gateway:

Service What it does
tls-cert Makes a self-signed certificate into the tls-certs volume and exits. It keeps the existing certificate unless it does not cover the configured domain.
https nginx with deploy/nginx/gateway.conf. It terminates TLS on 127.0.0.1:443 and proxies to gateway:8080.

The certificate covers gamewarden.test, localhost, host.docker.internal, gateway and 127.0.0.1. It is valid for 825 days. Plain HTTP on http://127.0.0.1:8080 keeps working.

HTTPS encrypts the connection, nothing more. The demo gateway still runs with --dev-auth, so anyone who can reach the port can act as any player. Both ports bind to loopback only; keep it that way.

Terminal window
docker compose up -d --build
docker compose ps -a tls-cert https

tls-cert shows Exited (0) and https shows Up. Check it before you change anything on your machine; -k skips the certificate check for now:

Terminal window
curl -sk https://localhost/healthz

You should see {"status":"ok"}.

Add one line to your hosts file. It needs administrator rights.

macOS and Linux:

Terminal window
echo "127.0.0.1 gamewarden.test" | sudo tee -a /etc/hosts

Windows: open Notepad as administrator, open C:\Windows\System32\drivers\etc\hosts and add 127.0.0.1 gamewarden.test.

Check that the name resolves:

Terminal window
curl -sk https://gamewarden.test/healthz

The certificate lives in the tls-certs volume. Copy it from the running https service:

Terminal window
docker compose cp https:/etc/nginx/certs/tls.crt ./gamewarden-dev.crt

gamewarden-dev.crt in the repository root is in .gitignore. Copy only tls.crt. The private key tls.key stays in the volume and must never leave it.

To see what you copied:

Terminal window
docker run --rm -v "$PWD/gamewarden-dev.crt:/c.crt:ro" alpine/openssl:3.5.4 \
x509 -in /c.crt -noout -subject -ext subjectAltName -enddate

Trust it on your own machine only, and only for TLS.

Terminal window
sudo security add-trusted-cert -d -r trustRoot -p ssl \
-k /Library/Keychains/System.keychain ./gamewarden-dev.crt

-d adds it to the System keychain, so Safari, Chrome and command line tools trust it. -p ssl limits the trust to TLS. To do the same by hand, double-click the file, add it to the System keychain, open it, and under Trust set Secure Sockets Layer (SSL) to Always Trust.

Terminal window
sudo cp ./gamewarden-dev.crt /usr/local/share/ca-certificates/gamewarden-dev.crt
sudo update-ca-certificates

On Fedora and RHEL copy it to /etc/pki/ca-trust/source/anchors/ and run sudo update-ca-trust. Chrome on Linux keeps its own store: import the file under Settings, Privacy and security, Security, Manage certificates, Authorities.

In an administrator PowerShell:

Terminal window
certutil -addstore -f Root .\gamewarden-dev.crt

Firefox uses its own certificate list on every system. Import the file under Settings, Privacy and Security, Certificates, View Certificates, Authorities, Import and tick “Trust this CA to identify websites”. On macOS and Windows you can instead set security.enterprise_roots.enabled to true in about:config.

Restart the browser after trusting the certificate.

Without -k this time:

Terminal window
curl -s https://gamewarden.test/healthz
curl -s -X POST -H 'X-Dev-Player: p1' -d '{}' \
https://gamewarden.test/v1/tools/get_city_state/call

The second command returns the city of player p1. The MCP endpoint is https://gamewarden.test/mcp.

If you have not trusted the certificate system wide, point curl at the file instead: curl --cacert ./gamewarden-dev.crt https://gamewarden.test/healthz.

Your hosts file does not apply inside containers, and the trust store of your machine does not either. A container needs a route to the proxy and the certificate.

On the compose network (works on every system). The https service answers to the alias gamewarden.test there. Mount the volume and tell the client where the certificate is:

Terminal window
docker run --rm --network gamewarden_default -v gamewarden_tls-certs:/certs:ro \
curlimages/curl:8.11.1 -s --cacert /certs/tls.crt https://gamewarden.test/healthz

The network and volume names start with the compose project name, gamewarden unless you changed it. A service in docker-compose.yml mounts tls-certs:/certs:ro and uses the same URL.

From outside the compose network (Docker Desktop). Use https://host.docker.internal, which is on the certificate. On Linux this name needs --add-host host.docker.internal:host-gateway, and a port bound to 127.0.0.1 is not reachable that way, so use the compose network there.

Go programs, such as the MCP bridge, read the SSL_CERT_FILE variable. Set it to the mounted certificate instead of turning verification off:

Terminal window
docker compose build bridge
docker run -i --rm --network gamewarden_default \
-v gamewarden_tls-certs:/certs:ro -e SSL_CERT_FILE=/certs/tls.crt \
gamewarden-bridge:latest --url https://gamewarden.test/mcp --header "X-Dev-Player: p1"

Other runtimes have their own variable: NODE_EXTRA_CA_CERTS for Node.js, REQUESTS_CA_BUNDLE for Python requests, CURL_CA_BUNDLE for curl.

The Toolkit starts MCP servers as containers, so the bridge above works there too. Save a server definition as ~/.docker/mcp/catalogs/city.yaml:

name: city
title: Gamewarden City
description: The example city game behind the local gateway (dev auth, HTTPS).
type: server
image: gamewarden-bridge:latest
command:
- --url
- https://host.docker.internal/mcp
- --header
- "X-Dev-Player: p1"
volumes:
- gamewarden_tls-certs:/certs:ro
env:
- name: SSL_CERT_FILE
value: /certs/tls.crt

Then create a profile and connect a client:

Terminal window
docker mcp profile create --name city --server file://city.yaml
docker mcp client connect claude-desktop --global --profile city

Restart the client. After you edit the file, refresh the profile with docker mcp profile server add city --server file://city.yaml.

Both are variables that docker compose reads from your shell or from a .env file next to docker-compose.yml (.env is in .gitignore):

Variable Default Effect
GAMEWARDEN_TLS_DOMAIN gamewarden.test The certificate’s name and the alias on the compose network. A new certificate is made on the next up when the name changes.
GAMEWARDEN_HTTPS_PORT 443 The host port. Use it when something else holds 443 or your Docker cannot bind ports below 1024 (rootless Docker on Linux).

Put them in .env so every later docker compose command sees the same values:

Terminal window
printf 'GAMEWARDEN_TLS_DOMAIN=city.gamewarden.test\nGAMEWARDEN_HTTPS_PORT=8443\n' >> .env
docker compose up -d

up makes the new certificate and restarts nginx with it. With another port, put it in every URL: https://city.gamewarden.test:8443. After a new certificate, repeat steps 2 to 4 with the new name.

The certificate stays until you delete the volume. To replace it:

Terminal window
docker compose down
docker volume rm gamewarden_tls-certs
docker compose up -d

docker compose down -v does the same but also deletes the Postgres data. Then copy and trust the new certificate (steps 3 and 4) and remove the old one from your trust store. On macOS:

Terminal window
sudo security delete-certificate -c gamewarden.test /Library/Keychains/System.keychain

Certificates for the same domain share that name, so run it before you add the new one.

Symptom Cause and fix
Could not resolve host: gamewarden.test The hosts line is missing. Do step 2. Inside a container, use the compose network or host.docker.internal (step 6).
Bind for 127.0.0.1:443 failed: port is already allocated Something else holds 443. Find it with sudo lsof -nP -iTCP:443 -sTCP:LISTEN, or set GAMEWARDEN_HTTPS_PORT.
SSL certificate problem: self-signed certificate The certificate is not trusted yet (step 4), or you trusted an older one. Compare the fingerprints of ./gamewarden-dev.crt and the one in the volume, then trust the current one.
no alternative certificate subject name matches The URL uses a name that is not on the certificate. Use one of the names under What runs, or set GAMEWARDEN_TLS_DOMAIN.
x509: certificate signed by unknown authority from the bridge SSL_CERT_FILE is not set, or the volume is not mounted at /certs.
502 Bad Gateway from nginx The gateway is not running or is restarting. Check docker compose ps gateway and docker compose logs gateway.
The browser still warns after you trusted it Restart the browser. Firefox needs its own import.