Publish your Docker apps with a domain and automatic HTTPS.
Total.js Proxy is a self-hosted reverse proxy for Total.js apps and other HTTP services. Point a domain at your server and tell Proxy which container to reach. Proxy routes requests by hostname, forwards WebSockets, and issues and renews Let's Encrypt certificates, including wildcards. Everything is set with files that Proxy watches: one JSON file for each site, or none at all when the containers publish themselves.
You need a Linux server with Docker and the ports 80 and 443 open. Proxy and your apps meet on one Docker network, named proxy.
Go to the folder where Proxy should live and run:
curl -fsSL https://raw.githubusercontent.com/totaljs/proxy/main/install.sh -o install.sh
bash install.shThe script makes the Docker network proxy and a folder proxy in the current folder with compose.yaml, .env, data and logs, then starts Proxy. It asks for sudo once, to give data and logs to the user of the container. Run it again to update to the newest image: a compose.yaml that is already there is kept. PROXY_DIR, PROXY_IMAGE and PROXY_NETWORK change the folder, the image and the network.
Then go to Publish an app.
1. Create the network and a folder for Proxy
docker network create proxy
mkdir -p /srv/proxy/data /srv/proxy/logs
cd /srv/proxy2. Save this as /srv/proxy/compose.yaml
services:
proxy:
image: totalplatform/proxy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./data:/proxy/data
- ./logs:/proxy/logs
- /var/run/docker.sock:/var/run/docker.sock:ro
group_add:
- "${DOCKER_GID}"
networks: [proxy]
networks:
proxy:
external: true3. Let the container write its folders and read the Docker socket, then start it
Proxy runs as the user node (UID 1000), not as root.
sudo chown 1000:1000 data logs
echo "DOCKER_GID=$(stat -c %g /var/run/docker.sock)" > .env
docker compose up -dProxy now answers on the server. A domain that has no site yet gets a page that says so.
Point the DNS of your domain to the server. In the Compose file of the app, say which domain it serves and on which port it listens, and put it on the proxy network:
services:
app:
image: totalplatform/run:npm
restart: unless-stopped
volumes:
- ./app:/www
environment:
PROXY_HOST: "https://example.com,https://www.example.com"
PROXY_PORT: "8000"
networks: [proxy]
networks:
proxy:
external: trueStart the app with docker compose up -d. Proxy sees the container, writes data/sites/example.com.json, gets a Let's Encrypt certificate for the names written with https:// and serves the app. When the container stops, the site goes with it. The app publishes no ports.
For an app that is not a container on this network, write the file yourself. Proxy applies it within a few seconds, without a restart:
/srv/proxy/data/sites/example.com.json
{
"hosts": ["https://example.com", "https://www.example.com"],
"target": "10.0.0.5:8000"
}docker compose logs proxy
cat logs/error.loglogs/error.log names anything that was not applied and why: a site file with a mistake, a certificate that could not be issued, an app that does not answer. Each site has its own logs/<site>.log.
| Path | What it holds |
|---|---|
compose.yaml, .env |
How the container of Proxy is started. |
data/config.json |
The settings of Proxy. Optional: without it the defaults apply. |
data/sites/ |
One JSON file for each site. |
data/certs/ |
The certificates of Let's Encrypt, and your own as <name>.crt + <name>.key. |
data/stats/ |
The request counters of each site. |
logs/ |
One log for each site and error.log. |
Back up data: it has the private keys. Every file is watched, so there is no command to check or reload anything.
Mounting the Docker socket lets Proxy see which containers publish themselves, and whoever has the socket controls Docker on that server. Docker discovery describes how to run without it.
Proxy is a Node.js program without dependencies. With Node.js 22 or newer, from a checkout of this repository:
node index.js datadata is the folder with config.json and sites/. Proxy makes it, and logs next to it, when they are not there.
-
Ports 80 and 443. A normal user cannot open them on Linux. Run Proxy as root, or let Node open them with
sudo setcap 'cap_net_bind_service=+ep' "$(command -v node)", or choose other ports indata/config.json:{ "http": 8080, "https": 8443 }. -
Keeping it running. The command stays in the foreground. On a server, run it under systemd or another process manager, so it starts again after a failure or a reboot:
[Unit] Description=Total.js Proxy After=network-online.target [Service] WorkingDirectory=/srv/proxy ExecStart=/usr/bin/node /srv/proxy/index.js data Restart=always User=proxy AmbientCapabilities=CAP_NET_BIND_SERVICE [Install] WantedBy=multi-user.target
-
Sites. Write the files of
data/sitesyourself; atargetcan be any address, such as127.0.0.1:8000for an app on the same machine. -
Docker discovery still works when the user of Proxy may read
/var/run/docker.sock, on Linux, where the addresses of the containers are reachable from the host. Set"docker": ""indata/config.jsonto turn it off.
Ctrl+C or SIGTERM stops Proxy; it writes its logs and counters first.
docker build -t totalplatform/proxy .- Install Proxy with the Compose files of this repository.
- Deploy Total.js Flow with Proxy for a complete example with a domain and automatic HTTPS.
- Configure Proxy:
config.json, site options, workers, wildcard domains and request counters. - Restrict app access with IP lists, passwords and per-route headers.
- Choose TLS per app for HTTP, automatic certificates or your own.
- Discover Docker apps: a container sets
PROXY_HOSTand its site appears, and goes when it stops. - Read the logs of each site and
error.log, with a size limit. - Operate and recover Proxy for health checks, backups and recovery.
- Run the tests, including certificate issuance and renewal with Pebble.
- Complete configuration example with a full
config.json, site files and Compose YAML.