How it works

tunl.surf is two programs. Both run on your machine. A request is not held at some other reception point.

Path of an HTTP request

  1. The client goes to the public address

    The address has the form name.127.0.0.1.sslip.io. 127.0.0.1.sslip.io resolves to this machine. The port is the HTTP endpoint: 8080 by default.

  2. aditd accepts the request

    The server reads the tunnel name from the Host header. If an edge rule is set, it is applied here. If the rule does not match, the request does not go to the agent.

  3. The agent writes to the local port

    tunl is connected to the control port (127.0.0.1:7000). The server hands the request to the agent over that connection. The agent sends it to the local endpoint you opened with --host and the port. If the agent is on another machine, encrypt that connection with TLS.

    The endpoint tells the local application who the client is, as follows. X-Forwarded-For ends with the address that connected. The visitor's own X-Forwarded-For, Forwarded, and X-Real-IP headers are not forwarded to the application: nobody has vouched for them, so the application sees only the address that connected. If a reverse proxy sits in front, name it with aditd --trusted-proxy; on a connection from that proxy the chain is kept and the connecting address is appended. X-Forwarded-Proto is http or https. X-Forwarded-Host is the name that was requested. A header rule can remove these names.

    The path and the query go to the local endpoint as the client sent them. A semicolon in the query, and a broken percent escape, are not dropped.

  4. The response returns the same way

    The local application's response goes from the agent to the server, and from there to the client. The inspector records the pair.

If the command has no --name, the server picks a temporary name. Example: amber-gate-k4w7zq. The last six characters are chosen at random each time; a tunnel cannot be reached by guessing the address. This name is not written to adit-data.json. When the process exits, the name goes with it and that tunnel's inspector record is deleted.

--name demo fixes the address. A name is at least 3 and at most 40 characters. Only lowercase letters, digits, and hyphens are used. A hyphen cannot be first or last. These names cannot be used: www, api, panel, mail, ftp, app, assets, kilavuz, guide, tor, healthz, adit, and tunl.

While the agent is offline

A reserved name stays on disk. If the agent is not connected, the request returns 503: the name is reserved, the agent is not connected. There is no separate endpoint that holds the request.

How TCP differs

A raw port has no Host header. The server picks a port from 19000–19040 on 127.0.0.1. The client connects to that tcp:// address. The detail is on the raw port page.

Not in this version