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.
What runs
Section titled “What runs”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.
1. Start the stack
Section titled “1. Start the stack”docker compose up -d --builddocker compose ps -a tls-cert httpstls-cert shows Exited (0) and https shows Up. Check it before you change anything on
your machine; -k skips the certificate check for now:
curl -sk https://localhost/healthzYou should see {"status":"ok"}.
2. Point the domain at your machine
Section titled “2. Point the domain at your machine”Add one line to your hosts file. It needs administrator rights.
macOS and Linux:
echo "127.0.0.1 gamewarden.test" | sudo tee -a /etc/hostsWindows: open Notepad as administrator, open C:\Windows\System32\drivers\etc\hosts and add
127.0.0.1 gamewarden.test.
Check that the name resolves:
curl -sk https://gamewarden.test/healthz3. Copy the certificate out of Docker
Section titled “3. Copy the certificate out of Docker”The certificate lives in the tls-certs volume. Copy it from the running https service:
docker compose cp https:/etc/nginx/certs/tls.crt ./gamewarden-dev.crtgamewarden-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:
docker run --rm -v "$PWD/gamewarden-dev.crt:/c.crt:ro" alpine/openssl:3.5.4 \ x509 -in /c.crt -noout -subject -ext subjectAltName -enddate4. Trust the certificate
Section titled “4. Trust the certificate”Trust it on your own machine only, and only for TLS.
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.
Linux (Debian and Ubuntu)
Section titled “Linux (Debian and Ubuntu)”sudo cp ./gamewarden-dev.crt /usr/local/share/ca-certificates/gamewarden-dev.crtsudo update-ca-certificatesOn 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.
Windows
Section titled “Windows”In an administrator PowerShell:
certutil -addstore -f Root .\gamewarden-dev.crtFirefox
Section titled “Firefox”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.
5. Check it end to end
Section titled “5. Check it end to end”Without -k this time:
curl -s https://gamewarden.test/healthzcurl -s -X POST -H 'X-Dev-Player: p1' -d '{}' \ https://gamewarden.test/v1/tools/get_city_state/callThe 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.
6. Reach it from other containers
Section titled “6. Reach it from other containers”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:
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/healthzThe 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:
docker compose build bridgedocker 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.
Docker Desktop MCP Toolkit
Section titled “Docker Desktop MCP Toolkit”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: citytitle: Gamewarden Citydescription: The example city game behind the local gateway (dev auth, HTTPS).type: serverimage: gamewarden-bridge:latestcommand: - --url - https://host.docker.internal/mcp - --header - "X-Dev-Player: p1"volumes: - gamewarden_tls-certs:/certs:roenv: - name: SSL_CERT_FILE value: /certs/tls.crtThen create a profile and connect a client:
docker mcp profile create --name city --server file://city.yamldocker mcp client connect claude-desktop --global --profile cityRestart the client. After you edit the file, refresh the profile with
docker mcp profile server add city --server file://city.yaml.
Change the domain or the port
Section titled “Change the domain or the port”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:
printf 'GAMEWARDEN_TLS_DOMAIN=city.gamewarden.test\nGAMEWARDEN_HTTPS_PORT=8443\n' >> .envdocker compose up -dup 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.
Make a new certificate
Section titled “Make a new certificate”The certificate stays until you delete the volume. To replace it:
docker compose downdocker volume rm gamewarden_tls-certsdocker compose up -ddocker 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:
sudo security delete-certificate -c gamewarden.test /Library/Keychains/System.keychainCertificates for the same domain share that name, so run it before you add the new one.
When it does not work
Section titled “When it does not work”| 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. |
- Play the example game with an agent over the same stack.
- Add your manifest to the gateway to run your own game behind it.
- Troubleshooting for result codes from the gateway itself.