Skip to Content
Acclimate
Operate

Use your own reverse proxy

Replace the bundled Caddy with your own proxy while keeping Acclimate's HTTPS origins, private listeners and trusted proxy headers.

To replace the bundled Caddy with your own proxy, such as nginx or Traefik, it must do what Caddy does. No replacement proxy has been tested. Self-host Acclimate needs no proxy changes.

Match the bundled proxy

RequirementFor both the console and the API hostname
TLSTerminate TLS and redirect public HTTP to HTTPS.
RoutingSend the console hostname to console:3100 and the API hostname to service:3000, over plain HTTP.
HostSet the upstream Host to the fixed public host for that route. For the console, use the host from CONSOLE_ORIGIN, with the port if you use a nondefault HTTPS port.
Forwarding headersRemove incoming Forwarded and all X-Forwarded-* headers. Set X-Forwarded-Proto to https, X-Forwarded-Host to the fixed public host and X-Forwarded-For to the peer IP address your proxy observed, without a client-supplied chain.
Request contentsPreserve paths and query strings, including /auth/callback, console cookies, the request Origin and the API Authorization header.
Body limitLet API requests reach the service's 2 MiB limit. A proxy that enforces it returns its own 413 response.
TimeoutSet the upstream response timeout slightly above 30 seconds, so the service returns its own timeout response.
Private listenersDo not expose either listener, either PostgreSQL database or the proxy's admin interface.

The console rejects a request for any other host and ignores forwarding headers that a caller supplies. Register the exact public console origin plus /auth/callback with Keycloak.

Allow task imports

A proxy that applies 2 MiB or 30 seconds to task import rejects or cuts off larger imports.

HostRequestBody limitTime allowed
APIPOST /v1/workspaces/{workspaceId}/bundles/{bundleId}/learning/tasks/import64 MiB600 seconds
ConsolePOST /learning-import64 MiB610 seconds

Keep Keycloak sign-in working

With the co-hosted Keycloak, your proxy also serves the Keycloak hostname.

  • Forward only /realms/acclimate, /realms/acclimate/*, /resources/* and /robots.txt to keycloak:8080, and answer every other path yourself, as the bundled configuration does with a 404.
  • Apply the same header rules with the Keycloak hostname.
  • Keep /admin, the master realm and the management listener private. The admin console is on Keycloak's loopback port, as in Manage people.
  • Containers on the private network reach the issuer at its public HTTPS name, which compose.keycloak.yaml gives the proxy container as an alias on the backend network. Your proxy needs the same alias.

Run without the bundled proxy

compose.yaml defines Caddy as the proxy service. To leave it out, start the other services by name:

docker compose up -d --build --wait postgres service console
  • Compose still needs CONSOLE_HOST, API_HOST and ACME_EMAIL in .env.
  • The console and the service listen only on the internal Compose network backend, which has no outside route. Your proxy must join it, with a second network or the host's ports for public traffic, as the bundled proxy does with edge.

Run behind a load balancer

Keep Caddy and send the balancer's traffic to it. Caddy routes by hostname, so the balancer must keep the client's Host header and TLS server name.

Balancer modeCaddy's certificates
TCP passthrough on 443 and 80Caddy's ACME certificates work unchanged.
TLS termination, then HTTPS to Caddy on 443Caddy needs a certificate the balancer accepts: its own, with port 80 forwarded from the internet, or yours.
TLS termination, then plain HTTP to CaddyNot supported. Caddy redirects HTTP to HTTPS.

To change Caddy's ports or certificates, write an override file in the private directory and append its absolute path to COMPOSE_FILE in .env, after a :. This one accepts traffic only on a private address and mounts a copy of deploy/keycloak/Caddyfile, or of deploy/Caddyfile without the co-hosted Keycloak, with a tls <certificate> <key> line in each site block. The console trusts only public certificate authorities, so a co-hosted Keycloak's certificate must come from one.

~/.config/acclimate/compose.edge.yaml
services:
  proxy:
    ports: !override
      - "10.0.0.5:80:80"
      - "10.0.0.5:443:443"
    volumes:
      - /home/ops/.config/acclimate/Caddyfile:/etc/caddy/Caddyfile:ro
      - /home/ops/.config/acclimate/certs:/etc/caddy/certs:ro

Check the result with docker compose config --quiet, then run docker compose up -d --wait proxy.

When your proxy is in place, run the checks in Verify API access and sign-in through it.

On this page