Skip to content

sync-proxy

An HTTP (CONNECT) and SOCKS5 proxy for morzer's targets: sync and backups, to S3 now and to git repositories once morzer syncs to git. Every machine that names it reaches the bucket from this machine's address, so the store's log holds one address instead of each machine's, and no longer shows which machines share a bucket.

It runs Xray from platform-images, pinned by tag and digest, with a login per machine. A login reaches the names you list, on port 443, and nothing else: an address, a private one most of all, is refused even when a listed name resolves to it.

Install

Give it a machine whose address you don't mind the store seeing, apart from the dotdash servers and relays: every machine that names it says so in its own configuration.

  1. Firewall: open the port you publish, 1080/tcp for SOCKS5 or 3128/tcp for HTTP, to your machines' addresses alone where your provider's firewall can, and install Docker and morzer as on every dotdash machine.
  2. Install, listing the names your targets reach:

    sudo morzer init --release oci://ghcr.io/morzecrew/dotdash-utils/sync-proxy:stable \
      --recovery-recipient age1… --set destinations=s3.example.net
    

    More names later, one per line: sudo morzer config edit destinations.

  3. Logins, one per machine, below:

    sudo morzer secret edit users
    sudo morzer apply
    
  4. Check it from inside, below, then point each machine at it.

init prints the release's signing key and trusts it from then on. To check even this first release, add --signing-key with the release key this repository publishes.

Logins

The users secret holds one <user>:<password> per line, one line per machine, with an optional # comment after it. Blank lines and lines that start with # are skipped. Both proxies take the same list:

# <user>:<password>   # <machine>
relay-1:2f0c…   # relay-1.example.net
backup-host:Zx+3…
  • User: 1 to 64 of a-z, 0-9, ., _ and -, starting with a letter or a digit.
  • Password: 20 to 255 visible ASCII characters other than :, such as openssl rand -hex 24 prints.
  • Add a machine with sudo morzer secret edit users, which restarts the proxy with the new list. Revoke one by deleting its line.

The proxy does not start on a list it refuses, and its log names the line and why, never the value: a user listed twice, a password too short, a line without a colon, or no line at all.

Pointing a machine at it

On each machine, keep its login in a secret of its own, relay-1:<its password> typed at the prompt, then name the proxy and that secret for each target:

sudo morzer secret set sync_proxy_login
sudo morzer backup target add s3://backups.example/fleet/relay-1 --credentials backup_s3 \
  --proxy socks5h://proxy.example.org:1080 --proxy-credentials sync_proxy_login
sudo morzer config set sync.proxy=socks5h://proxy.example.org:1080
sudo morzer config set sync.proxy_credentials=sync_proxy_login

morzer never goes around a proxy it names: when none answers, the fetch or backup fails and says why (reaching a target through a proxy). Name a second proxy after the first to keep a way when this machine is down.

  • socks5h:// says the proxy resolves the target's name, which is what destinations matches. morzer hands the name to the proxy under socks5:// too, so both work with it; other clients, curl among them, resolve the name themselves under socks5:// and send an address, which is refused.
  • http:// is the HTTP proxy's CONNECT, on http_port.
  • A sync hint read through a DNS over HTTPS resolver (sync.hint_resolver) goes through the same proxies: list the resolver's name in destinations too.

Parameters

Set one with sudo morzer config set <name>=<value>.

Name Default
destinations none, given at init the names a login may reach, one per line (# starts a comment, and commas separate too; morzer config edit destinations): a bucket's or a git host's endpoint, such as s3.example.net, or *.example.net for every name under it and example.net itself, as a bucket reached by its own name (bucket.s3.example.net) needs. An address is refused here, as it is through the proxy
ports 443 the destination ports a login may reach, comma-separated, each a port or a range such as 8000-8099. 443 is HTTPS, which S3 and git over HTTPS use
allow_from any the client addresses let in, comma-separated addresses and CIDRs such as 198.51.100.0/24, or any. A client outside them is refused even with a login
http_port 3128 host port of the HTTP proxy, published on listen
socks_port 1080 host port of the SOCKS5 proxy, published on listen
listen empty the host address both ports are published on: empty for every address, IPv4 and IPv6; 0.0.0.0 for every IPv4 address alone; or one of this machine's addresses

A value the bundle can't use, such as a name with a space or a port that is not a number, is refused when it is set; one Xray refuses, such as a port past 65535, is rolled back when the proxy doesn't start. Nothing changes either way.

One proxy alone

Both proxies are published unless a profile says otherwise:

sudo morzer config set installation.profile=socks-only   # or http-only
sudo morzer config unset installation.profile           # both again

The other proxy's port is then not published, and Xray doesn't listen for it.

What it refuses

Deny by default, checked twice:

  • Routing. A request goes out only when it carries a login from users, comes from allow_from, and asks for a listed name on a listed port over TCP. A name that resolves to a private, loopback, link-local, CGNAT, multicast or documentation address is refused, 169.254.169.254 among them, and so is any address asked for directly. Everything else gets a 403.
  • At the dial. The outbound checks every address a name resolves to before it connects, and the address it connected to after, so a name that answers a public address to the check and a private one to the dial is still refused.

SOCKS5 takes a login alone: SOCKS4, which has no password, and UDP are refused. The proxy reads nothing a client sends to steer its routing. Its log holds errors alone, with no access log, so it keeps no record of who connected or where to, and it never logs a login.

Threat model

  • The login crosses to the proxy in the clear. morzer has no https:// proxy scheme yet, so a machine sends its login to the proxy unencrypted, over HTTP Basic or the SOCKS5 password exchange (morzer#512). Anyone on the path can read it.
  • What a leaked login reaches. Only the names in destinations, on the ports in ports: the same buckets and git hosts the machine already reaches, from this machine's address. It can't reach this machine's network, its cloud metadata, or anywhere else. Revoke it by deleting its line.
  • The traffic itself. A target's TLS runs from the machine to the store, end to end, through the tunnel: the proxy sees the name and the size and timing of the traffic, never what it carries, and morzer refuses a plain http:// endpoint behind a proxy.
  • It is a plain proxy. Its handshakes are visible to anyone who inspects traffic, and easy to block. A dotdash relay inside a filtered network should keep syncing through its own tunnel rather than through this.
  • One login per machine. Shared, a leak means rotating every machine; one each, you delete one line.

allow_from narrows who may try a login at all. Docker publishes a port on IPv6 through a proxy of its own, so an IPv6 client reaches Xray from the Docker network's gateway rather than its own address, and allow_from refuses it unless it lists that gateway. With allow_from set, publish on an IPv4 address (listen=0.0.0.0 or the machine's own) or connect over IPv4.

Tasks

Task
check --output from inside the project's network, through each proxy published: a request without a login, one to a name off the list, and ones to 169.254.169.254, 127.0.0.1 and 10.0.0.1 are refused, and each exact name in destinations completes a TLS handshake through it. When a listed name doesn't, because it is unreachable from here, resolves to a private address, or this check's own address is outside allow_from, it says which and skips it. It fails only when something that must be refused gets through

Health

doctor and each apply pass while the container's own check does: a request through a loopback-only inbound to Xray's own metrics, which reaches nothing outside the container and needs no name on the list.

It keeps nothing but its parameters and the users secret, both in morzer's state and its backups, so a backup holds no product data and morzer restore restores nothing: recovering a lost machine brings both back.