The edge role
The network redesign of 2026-10-27 changes this page. hopbox leaves the vRack and the OVHcloud API, and the servers talk over their public addresses (Q90). This page still describes the current code. Milestones N26 to N32 change the code and this page. Before you set up a fleet on the vRack, read Q90.
The edge role is the HTTPS front of an install. It takes the HTTPS traffic of every client, and it routes each request by its host name. The domain of the install goes to the control role, which serves the API and the console. A machine URL, such as box1.example.com, goes to its machine. A private machine URL needs a sign-in first. This page covers the listeners, TLS, the routing, and the forwarded requests. It also covers the machine URLs, the sign-in of a private machine URL, the public IPv6 address of an edge server, EdgeService, the metrics, and the logs. The edge role also runs the SSH front door of the machines, which the SSH front door covers.
The edge role is in internal/edge. The pushes of the control role are in internal/control/channel/edge.go. The routes and the sign-in are in internal/service/edge.go. EdgeService, /auth/machine, and the forwarded requests are in internal/api/edge.go.
In the examples, the domain of the install is example.com.
Listeners
Section titled “Listeners”The edge role has two HTTP listeners, and the listener of the SSH front door (the SSH front door). Their addresses are in the section [edge] of the bootstrap config (the bootstrap config of hopboxd).
| Item | Value |
|---|---|
| HTTPS listener | edge.https_listen. Default: :443, port 443 on every address. |
| HTTP listener | edge.http_listen. Default: :80. It only sends each request to HTTPS (HTTP to HTTPS). |
| Protocols | HTTPS: HTTP/2 and HTTP/1.1, by ALPN. HTTP: HTTP/1.1. |
| Open connections | At most 16,384 on the HTTPS listener, and 65,536 on the HTTP listener, of the 1,048,576 file descriptors that hopboxd.service allows. The bound of the HTTPS listener keeps the memory of its connections under 4 GiB (Memory of stalled requests). A connection past the bound of the listener gets no refusal. It waits in the backlog of the kernel until another one closes. So a full HTTPS listener stops new console sessions and new CLI connections, with no error page. The open connections go on. hopbox_edge_open_connections and hopbox_edge_connection_limit show how full each listener is (Metrics). |
| Open connections of one client | At most 256 on each listener. A client is an IPv4 address, or the /64 of an IPv6 address. The edge role closes a connection past this bound at once, so one client cannot hold every slot of a listener. Each one counts in hopbox_edge_client_connection_refusals_total{bound="client"}. |
| Open connections of one IPv6 network | At most 1,024 on each listener, for all /64s of one IPv6 /48 together. The holder of a /48 has 65,536 /64s, enough to fill a listener alone. The edge role closes a connection past this bound at once. The count of its /64 does not matter. Each one counts in hopbox_edge_client_connection_refusals_total{bound="network"}. An IPv4 address has no such bound (Clients behind one network). |
| Request header | At most 64 KiB, also on HTTP/2. A larger header gets 431 Request Header Fields Too Large. |
| Header timeout | 10 s for the header of a request. A slow client then loses its connection. |
| Idle timeout | 2 min without a request closes a connection. |
| HTTP/2 streams | At most 250 at once on one connection. |
| HTTP/2 receive buffer | 256 KiB for each stream, and 250 times that for the connection. So a stream whose target reads nothing, such as an exec with unread input, stalls alone. The other streams of the connection go on. |
| Open requests | At most 16,384 at once on the HTTPS listener, streams and WebSockets included. A request past the bound gets 503 Service Unavailable with Retry-After: 1 and Hopbox-Not-Run: 1. |
| Open requests of one client | At most 1,024 at once. A request past the bound gets 429 Too Many Requests with Retry-After: 1 and Hopbox-Not-Run: 1, so one client cannot take every slot of the 16,384. A client is an IPv4 address or the /64 of an IPv6 address. |
| Open requests of one IPv6 network | At most 4,096 at once, for all /64s of one IPv6 /48 together. A request past the bound gets 429 Too Many Requests with Retry-After: 1 and Hopbox-Not-Run: 1. The count of its /64 does not matter. So one /48 can take at most a quarter of the 16,384. Watch hopbox_edge_requests_total{to="refused"} for the refusals of both bounds. |
| HTTP/2 frames | At most 16 KiB for each frame that a client sends. |
| Request body on HTTP/1.1 | A body that sends nothing for 1 minute while its target reads it ends. The edge role then answers, and closes the connection. A body that keeps sending has no time limit. If an answer ends before the whole body was read, the edge role sends the whole answer at once, reads no more of the body, and closes the connection. That holds for the answers of a target and for the answers that the edge role makes itself, such as a refusal of the bounds, a sign-in, or the 502 Bad Gateway when no control server or machine takes the request. It holds for a body with a Content-Length and for a chunked body, and for an answer of every status. So a client that still sends its body gets the whole answer and its end. If the forward fails after the target took the request, the 502 Bad Gateway comes only once the body ends, or once it sends nothing for 1 minute. |
| Answer, HTTP/2 streams, and WebSockets | No timeout, so streams, downloads, and WebSockets can last. |
Clients behind one network
Section titled “Clients behind one network”The bounds of a client and of an IPv6 network count by address. So all people behind one address share its slots, also with their long streams, such as an office or a carrier with one NAT.
| Network | What it shares |
|---|---|
| One IPv4 address | 256 connections on each listener, and 1,024 open requests. A carrier NAT can put thousands of people behind one address. IPv4 has no bound of a wider network, because the next addresses often belong to other people. |
| One IPv6 /64 | 256 connections on each listener, and 1,024 open requests. One host usually holds a whole /64. |
| One IPv6 /48 | 1,024 connections on each listener, and 4,096 open requests, for all its /64s together. One site, such as an office or a server of a hosting provider, usually holds a /48. A carrier or a hosting provider can also give many customers a /64 each in one /48. These customers then share the bounds of the /48. |
Without the bound of a /48, 64 /64s of one /48 fill the 16,384 connections of the HTTPS listener. With it, a client needs 16 /48s. A lower bound for each /48 keeps the listener open for more networks, but it stops more users of a shared /48. The bound is 1,024 connections for each /48. If the users of a large network reach the bound, hopbox_edge_client_connection_refusals_total{bound="network"} and hopbox_edge_requests_total{to="refused"} grow.
Memory of stalled requests
Section titled “Memory of stalled requests”A request can stall in two ways. Its target reads none of its body, or its client reads none of the answer. A stalled request holds memory in the edge until it ends, because no timeout ends an HTTP/2 stream. The bounds of open requests cap that memory. At the end of each request, the edge closes its body. So an HTTP/2 stream whose answer waits for the window of the client holds no body:
| Buffer of one request | Size |
|---|---|
| The request header | At most 64 KiB. |
| The body on HTTP/2 | At most 256 KiB, the receive buffer of the stream. |
| The answer of the control role | At most 64 KiB, the receive buffer of the stream to the control role. |
| The frame buffer of the body to the control role | 64 KiB, the largest frame that the internal listener reads (the internal listener). |
| The copy buffers of the proxy | 32 KiB in each direction. |
So one request holds at most 512 KiB. A connection also holds memory without a request:
| Buffer of one HTTPS connection | Size |
|---|---|
| The read buffer of the HTTP/2 framer | At most 16 KiB, the largest frame. |
| The write buffer of the HTTP/2 framer | About 16 KiB. |
| The TLS records | About 17 KiB in each direction. |
| The HPACK tables | 4 KiB in each direction. |
| The save buffer of the HPACK decoder | Up to about 64 KiB, for a header in CONTINUATION frames. |
| The stacks of its goroutines | 16 KiB to 32 KiB each after the TLS handshake. |
| The structs of the connection | Some KiB. |
The edge counts 256 KiB for one HTTPS connection. A connection of the HTTP listener holds a read buffer and a write buffer of 4 KiB. It also holds a stack, its structs, and the wrappers of the listeners. An idle one takes about 20 KiB. The edge counts 32 KiB for it. So the bounds are these:
| Who | Most memory |
|---|---|
| One client | 584 MiB: 256 HTTPS connections of 256 KiB, 256 HTTP connections of 32 KiB, and 1,024 requests of 512 KiB. |
| One IPv6 /48 | 2.3 GiB: 1,024 HTTPS connections of 256 KiB, 1,024 HTTP connections of 32 KiB, and 4,096 requests of 512 KiB. |
| The HTTPS listener | 12 GiB: 16,384 connections of 256 KiB, and 16,384 requests of 512 KiB. |
| The HTTP listener | 2 GiB: 65,536 connections of 32 KiB. |
A test of internal/edge checks these bounds against the defaults.
The answer of a machine and the body of a request on HTTP/1.1 wait in the socket buffers of the kernel, not in hopboxd. The kernel parameters net.ipv4.tcp_rmem, net.ipv4.tcp_wmem, and net.ipv4.tcp_mem bound them. Each HTTP/1.1 connection to a machine also holds a read buffer and a write buffer of 4 KiB in the edge.
The unit edge of hopboxd run opens the listeners at its start (hopboxd). If another program holds a port, the start fails, and hopboxd exits with status 1. The error names the address, such as edge: listen on :443: bind: address already in use. Ports 443 and 80 need root, and hopboxd.service runs hopboxd as root (Server layout).
At a stop, the unit ends the SSH connections, closes the listeners, gives the open requests 2 s, and then ends the rest: streams, WebSockets, and long calls. The whole stop takes at most 5 s.
The edge role serves one certificate: the wildcard certificate of the install, for the domain and *.<domain> (the certificate of the install). The control role pushes the certificate with its key over the control channel (the control channel). The edge role keeps it only in memory.
| Rule | Value |
|---|---|
| TLS versions | 1.2 and 1.3. The cipher suites are the defaults of Go. |
| Server name (SNI) | Required. A handshake without a server name fails. |
| Host names | The domain, and each name under it. A handshake for another name fails. |
| Before the first certificate | Every handshake fails. |
| Certificate of another domain | When the domain of the install changes, the edge role refuses every handshake until the certificate of the new domain arrives. It never serves the certificate of the old domain. |
When the role edge leaves a running server, the end of the removal restarts hopboxd without the role (the admin API). The new process has no copy of the certificate of the install, of its key, or of the SSH host key of the install. The edge role keeps them only in memory, and writes none of them to the disk (hopboxd). The control store keeps them for the other edge servers. hopboxd install drops the table edge from the config with the role, edge.public_ipv4, edge.floating_addresses, and edge.public_ipv6 among its keys. So the check of the uplink, which runs only with the edge role, puts no floating address back. The host firewall closes ports 80, 443, and the SSH ports of the machines, and port 22 takes only jump_hosts from then on (the host firewall). The Terraform provider then takes the floating addresses off the uplink (hopbox Terraform provider).
The edge role checks each certificate that the control role pushes before it serves it. It refuses a certificate in each of these cases, and keeps the certificate that it has:
- The domain of the message is not a domain in lowercase without a final dot.
- The leaf does not cover the domain, or a name under it.
- The leaf is not valid now.
- The key is not a PKCS #8 key, or it does not match the leaf.
A handshake that fails counts in hopbox_edge_tls_refusals_total (Metrics).
Routing
Section titled “Routing”The edge role routes each HTTPS request by its host. The host is the Host header, or the :authority of HTTP/2, in lowercase, without a port and without a final dot.
| Request | Answer |
|---|---|
| The host is not the server name of the TLS connection, and one of the two is not a name of the certificate: the domain, or one label under it | 421 Misdirected Request. A browser sends the requests of every name of a certificate on one HTTP/2 connection, so those pass. A host outside the certificate does not, also in a request in the absolute form, such as GET https://other.example/. |
Method CONNECT |
405 Method Not Allowed. The edge role is not a proxy. |
Host example.com, path under /hopbox.cluster.v1. |
404 Not Found. The cluster API is only for the servers of the install, on the internal listener. |
Host example.com |
Forwarded to the control role (Forwarded requests). |
Host grafana.example.com, while no machine holds the name grafana |
Forwarded to the control role with Hopbox-Forward-Target: grafana (The Grafana host). |
Host <name>.example.com |
The machine <name> (Machine URLs). |
Any other host under the domain, such as sub.box1.example.com |
404 Not Found. Subdomain routes come in phase 4. |
Each HTTPS answer carries the header Strict-Transport-Security: max-age=31536000; includeSubDomains (HSTS). A browser then reaches the domain and every machine URL only over HTTPS for a year.
An HTTP/1.1 request with the body encoding chunked gets Connection: close on its answer, also on a refusal of the bounds of open requests. Such a request can also have had a Content-Length header, which the server drops. Two such headers can hide a second request behind the first one, so the connection ends after the answer (RFC 9112, section 6.1). The server of Go refuses the other ambiguous requests. Two different Content-Length values, and a space before the colon of a header name, get 400 Bad Request. A Transfer-Encoding other than chunked gets 501 Not Implemented. A header line that continues on the next line reaches a machine as one line. The edge role builds a new request for each request that it forwards, so a forwarded request never carries the framing of the client.
The pages of the edge role are plain text, with Cache-Control: no-store and X-Content-Type-Options: nosniff. They also carry Content-Security-Policy: default-src 'none'; frame-ancestors 'none' and X-Frame-Options: DENY, so no page shows them in a frame. So do the redirects of the sign-in, and the pages of /auth/machine.
HTTP to HTTPS
Section titled “HTTP to HTTPS”The HTTP listener answers each request for the domain or a name under it with 301 Moved Permanently to the same host and path over HTTPS. For example, http://box1.example.com/a?b=1 goes to https://box1.example.com/a?b=1. A request for another host, or before the edge role knows the domain, gets 404 Not Found.
Forwarded requests
Section titled “Forwarded requests”The edge role forwards each request of the domain and of the Grafana host to the internal listeners of the control servers (the internal listener). It uses the dial order of the control channel: the URLs of the live control servers that the control role sent and the server keeps, then the URLs of channel.control_urls of the bootstrap config that are not among them (the control channel). Each new list of the control role replaces the order at once. A control server that stays in the order keeps its skip. It sends the requests to the live control servers in turn, one request after the other. It tries the other URLs of channel.control_urls in order after them, as fallbacks. Without a list from the control role, it sends the requests to the URLs of channel.control_urls in turn. Its EdgeService calls, such as the machine URL sign-in and the checks of the SSH front door, go the same way. A request that got no connection, because a dial or the TLS handshake failed, goes to the next control server with its body unread. The edge role then skips that control server for 10 s, so the next requests try the others first. A request that reached a control server and failed before its answer came does not go again, but the edge skips that control server for 10 s too. The HTTP/2 transport of the edge sends a request again on a new connection to the same control server when that server ended the old connection with GOAWAY before it took the request. A request with a body goes again too, while no try read its body. A request whose client went away, or whose deadline ended, marks no control server and goes to no other one. A short deadline of a caller says nothing of the control server. A dead control server still gets skipped: its connection fails the ping within 10 s, and a new dial to it fails within 3 s. A new connection to a control server has 3 s for its dial and 3 s for its TLS handshake: a dial to the peer address of a control server takes a few round trips of the internet, so a slower one is gone, and the request goes on to the next control server well within the deadline of its call. A control server that died hard leaves its HTTP/2 connection half open. So the edge pings a connection to a control server that sent nothing for 5 s, and closes it when the answer does not come within 5 s. The requests on it then fail, and the next requests go to the others. This covers Connect, gRPC, gRPC-Web, streams in both directions, trailers, the sign-in pages under /auth/, and the WebSocket of exec (/api/ws/exec). The end of the answer of the control server that took the request also ends the body of the request. So a stream whose answer ended, such as an exec at the exit of its command, ends while its client still holds its side of the stream open. The admin API is public behind the edge too, for admin API keys.
| Item | Value |
|---|---|
| Transport | Mutual TLS 1.3 with the server certificate of the edge server, against the install CA. HTTP/2 for every request but a WebSocket upgrade, which uses HTTP/1.1, because HTTP/2 cannot carry it. |
| Host | The host of the client request, such as example.com. |
Hopbox-Client-Addr |
The address of the client, IP:port. The edge role sets it over any value that the client sent. |
Hopbox-Forward-Target |
grafana on a request of the Grafana host (The Grafana host). On any other host, the request does not carry it. The edge role deletes any value that the client sent. |
X-Forwarded-For |
The IP address of the client alone. The edge role drops the value that the client sent. |
X-Forwarded-Host, X-Forwarded-Proto |
The host of the request, and https. |
Forwarded |
Dropped. |
| Flush | Each write of the control role goes to the client at once, so streams do not wait. |
| HTTP/2 receive buffer | 64 KiB for each stream, and 1 GiB for the connection, which holds the buffers of all 16,384 open requests. So an answer that one client does not read never stalls the answers of other clients. |
| Failure | 502 Bad Gateway with a page that says that the control plane did not answer. If the request got no connection to the control role, because of a dial or TLS error to every control server, the answer also carries Hopbox-Not-Run: 1. After a connection, the control role can have run the call, so the answer has no such header. |
The header Hopbox-Not-Run: 1 tells a client that the call changed nothing, so the client can retry it (the API server). The refusals of the bounds of open requests carry it too (Listeners).
The control role trusts Hopbox-Client-Addr and Hopbox-Forward-Target only on a connection whose certificate proves a server with the edge role (the internal listener). The rate limits of sign-in then count each client by its own address (Sessions, cookies, and sign-in links).
Machine URLs
Section titled “Machine URLs”The control role pushes the routes of the machine URLs over the control channel (the control channel). A route names a machine that holds its name and is not on its way out. A running machine has a target: the address of the machine on its node, its URL port, and its lease (Control store tables).
| Case | Answer |
|---|---|
| No machine has the name | The same answers as a private URL without a sign-in (Answers of a private URL). So a client cannot tell which names have a machine. After the sign-in, /auth/machine answers 404 Not Found, also for a machine that the account does not see. |
A path under /__hopbox/ other than /__hopbox/auth |
404 Not Found. The edge role keeps these paths for itself and never forwards one to a machine. |
| A private URL without a valid sign-in | The sign-in (Private machine URLs). A private URL tells nothing else about its machine before the sign-in. |
| An instance admin suspended the org of the machine | 403 Forbidden with the page An instance admin suspended the org of this machine. On a public URL, only a visitor with a sign-in of an account with access to the machine gets that page. Every other visitor gets The machine box1 is not available right now. (Q214 of the phase 3 plan). |
| The machine is in standby or hibernated | The edge role holds the request, and wakes the machine (Wake on connect). The request goes on to the machine once it runs. |
| The machine does not run | 503 Service Unavailable, with the state of the machine, such as The machine box1 is stopped. Start it, then retry. |
| The lease of the target ended at the edge | 503 Service Unavailable. The node of the machine did not renew its lease lately, so the machine can run on another node now. |
| The target has no address | 503 Service Unavailable, with the page The machine box1 runs, but it has no network address on its node, so its URL cannot reach it. Each machine gets an address at its create, so only a machine without one gets it (the node network). |
| The machine does not answer on its URL port | 502 Bad Gateway, with a page that says to check that a server listens on that port in the machine |
| Otherwise | Forwarded to the machine |
Wake on connect
Section titled “Wake on connect”A sleeping machine is a machine in standby or hibernated. The edge role resumes or wakes it only after the check of access of the request:
- A request for a public URL passes the check.
- A request for a private URL passes it with a valid sign-in of an account with access to the machine. A request without one gets the sign-in, and wakes nothing.
The edge role then holds the request, and calls EdgeService.WakeForConnection (EdgeService.WakeForConnection). The control role sets the target of the machine to running. Once the routes give the machine a target, the request goes on to the machine. So a client sees only a slower first answer. The requests that wait for one machine share one call.
The URL can turn private, or the access of a token can end, during the hold. So once the machine runs, the request takes the check of access again on the new route. A request of a URL that turned private gets the sign-in, and a token without access gets 403 Forbidden. Neither reaches the machine.
| Bound | Value | Past it |
|---|---|---|
| The hold of one request | 30 s | 503 Service Unavailable with Retry-After: 5 and the page The machine box1 did not wake: it did not wake within 30s. Retry. |
| The held connections of one machine, on each edge server | 256 | 503 Service Unavailable at once, with the page The machine box1 did not wake: 256 connections wait for its wake already. Retry later. |
| The wakes at once for the machines of one node, on each edge server | 16 | The next wake waits for a free slot, within the hold of its requests. |
The hold ends without the machine in these cases. Each one answers 503 Service Unavailable with Retry-After: 5, and a page that starts with The machine box1 did not wake: and names the reason.
The page of a public URL names the reason only to a visitor whose machine cookie proves a sign-in of an account with access to the machine. Every other visitor gets The machine box1 did not wake: this machine is not available right now. Retry later., also for a timeout or the bound of held connections (Q214 of the phase 3 plan). The edge checks the cookie with AuthorizeMachineRequest and read_only true, so the check keeps the console session of the cookie as it is. It sends no sign-in and no cookie. The answer for each cookie stays for 5 s: access, also the answer failed_precondition of a suspended org, which the control role gives only after the check of access passed, or no access, for unauthenticated, permission_denied, not_found, and invalid_argument. A control role that did not answer leaves no answer, and the page then shows the generic reason. A request of a private URL passed its sign-in before the hold, so its page always names the reason. The metrics and the logs keep the full reason. The same rule covers the 403 of a public URL of a suspended org.
| Case | Reason on the page |
|---|---|
| The control role refuses the wake: the org limits, the room of the node, a node without the feature, a suspended org, or a private machine of a suspended creator | The message of the control role, such as an instance admin suspended the creator of the private machine box1, so it does not resume or wake |
| The wake fails on the node | its wake failed, and it keeps its saved state. Its creator can start it again |
| Someone stops or deletes the machine during the hold | it is stopped now or it is deleted now |
| The control role does not answer | the control plane of this install did not answer. Retry later |
| The control role runs a release before the call | the control plane of this install runs a release that wakes no machine for a connection. Start the machine, then retry |
A refused or failed wake leaves the machine as it was. A hibernated machine keeps its memory file. A stopped or failed machine never wakes for a request.
The edge role keeps each refusal of the control role for 5 s, the value of Retry-After, or until the next routes. Each request of the machine in that time gets the same 503 at once, and asks the control role nothing. So a client in a loop with one cookie, or without one, costs the control role one wake call and one check of the cookie each 5 s, and no lock of the org row at each request. An error of a control role that did not answer is not kept.
The edge role counts each wake in hopbox_edge_wakes_total, and each held request that gets 503 as the cause waking of hopbox_edge_upstream_errors_total (Metrics). It records the time from the first packet of the connection to the first answer of the machine in hopbox_edge_wake_wait_seconds. For the first request of a connection, the first packet is the accept of the TCP connection. For a later request on the same connection, it is the start of the request.
Each heartbeat names at most 4096 machines with connections. With more, the agent logs the edge role holds connections of more machines than a heartbeat carries, so the heartbeat names only some of them at warn level, with machines and max.
An open connection that passed its check of access keeps its machine awake (Q181 of the phase 3 plan). Each heartbeat of the edge server names the machines with held requests, open forwarded requests, and signed-in SSH connections in connected_machines (the control channel). The control role then counts a use of each of them. If an idle timer put such a machine in standby or hibernated, the control role also sets its target back to running, with the checks of WakeForConnection and the actor system. Its audit entry has the reason open_connection. So a timer that acts in the seconds before the edge reports a new connection to a running machine leaves no session hung. A pause or a hibernate by any other actor stays, so a sleep by hand wins over an open connection. That holds also for a pause or a hibernate of a machine that an idle timer put in that state already. The owner decided this on 2026-11-11, in Q233. A new connection to such a machine still wakes it, as this section says above. The control role brings the machines back after its answer to the heartbeat, one pass at a time for each channel, for at most 15 s. So a lock of the org row delays no answer and no renewal of the leases. Each lock wait of such a change ends after 5 s, and Postgres ends it itself, with lock_timeout. So a machine whose org row stays locked delays each later machine of the pass by at most 5 s, and a pass of 15 s handles about 3 such machines. After a refused change, such as at a limit of the org, or a lock wait of more than 5 s, the heartbeats leave that machine for 1 minute, so a hung session does not lock the org row every 5 s. A scan that passes no check holds no machine awake.
The edge role counts the lease of each target from the arrival of the routes. The control role sends the rest of the lease, less a tenth of the machine TTL. It also takes off the time that the routes waited in its queue. After each heartbeat of the edge server, it sends the changed routes, or only the rest of the lease of each target. So the lease of a live target never runs out. If the control channel of the edge server ends, the targets run out within the machine TTL of 30 s. The machine URLs then answer 503 until the channel is back.
The edge role keeps each request that it forwards to a machine until it ends, such as a WebSocket or a long download. New routes end an open request at once in three cases: the machine has no route any more, its org is suspended, or its URL turned private. A request of a public URL has no sign-in, so it cannot stay open on a private URL.
What a machine gets
Section titled “What a machine gets”The edge role forwards a request to http://<address>:<url port> over HTTP/1.1, without TLS. The address is the address of the machine on its node (the node network). How the request reaches that address depends on the roles of the edge server (The way to the machines).
| Item | Value |
|---|---|
| Host | The machine host, such as box1.example.com. |
X-Forwarded-For |
The IP address of the client alone. |
X-Forwarded-Host, X-Forwarded-Proto |
The machine host, and https. |
Forwarded, Hopbox-Client-Addr, Hopbox-Forward-Target |
Dropped. Only the control role reads Hopbox-Client-Addr and Hopbox-Forward-Target. |
Cookie |
Each cookie of the client, except the cookies of hopbox: every name that starts with __Host-hopbox_, in any case. The other cookies stay as the client sent them. |
| WebSocket | An upgrade over HTTP/1.1 passes. |
| Answer header | At most 64 KiB. |
So the code of a machine never gets the machine cookie, nor a session cookie of the console. The cookies of the console are host-only __Host- cookies of the domain, so a browser never sends them to a machine host anyway (Sessions, cookies, and sign-in links).
The edge role also drops these Set-Cookie headers of an answer of a machine:
- A cookie whose name starts with
__Host-hopbox_, in any case. - A cookie with a
Domainattribute other than the machine host. Such a cookie can reach the console and the other machines of the install, which are on the same site as the machine.
A cookie without a Domain attribute, or with the machine host as its domain, passes.
The way to the machines
Section titled “The way to the machines”An edge server reaches each machine at the address of its route record. The way to that address depends on the roles of the edge server:
| Edge server | The way to a machine |
|---|---|
| With the node role, such as the first server of an install | The routes of the host. A machine of this server is behind its tap device. A machine of another node is behind the mesh device hbm0, with the route of the node subnet of that node (the mesh). |
| Without the node role, an edge server apart from the nodes | Only the mesh device hbm0. Each connection to a machine is bound to the device. So it leaves from the mesh address of the edge server, and never through another interface, such as the uplink, also while the mesh has no route to the address. The edge server refuses an address outside the machine range 10.240.0.0/12. |
The node of the machine lets a connection from hbm0 reach the machine only from the mesh address of an edge server. The control role names the edge servers in each mesh that it pushes, and the table inet hopbox_node of the node keeps them in its set edges (the node network). The machine sees the mesh address of the edge server as the source of each connection. The header X-Forwarded-For holds the address of the client.
The same rules hold for the SSH front door (the SSH front door).
An edge server without the node role and without a mesh device reaches no machine. Its machine URLs answer 502 Bad Gateway, and it logs forwarding a request to a machine failed with an error such as This edge server reaches the machines only over the mesh, and has no mesh device hbm0 yet. The mesh lists why a server stays out of the mesh.
Private machine URLs
Section titled “Private machine URLs”The URL of each machine is private by default. Only an account that uses the machine opens it: its creator, and every member of its org once the creator shares it. An org admin cannot open the private URL of a private machine of another member, as with a shell. The rule is the policy action machine.open_url (the API server). The creator makes the URL public with SetMachineURLVisibility (the machine API), if the limit public_urls of the org allows it. The personal org of a limited account does not allow it (the org API). A public URL needs no sign-in.
The sign-in of a private URL takes these steps. The machine is box1.
- A browser asks for
https://box1.example.com/page?x=1without a machine cookie. The edge role answers303 See Othertohttps://example.com/auth/machine?machine=box1&path=%2Fpage%3Fx%3D1. A path longer than 512 characters becomes/. - The control role reads the session cookie of the console at
/auth/machine. With a live session of an account that uses the machine, it makes a one-time code, and answers303 See Othertohttps://box1.example.com/__hopbox/auth?code=<code>&path=%2Fpage%3Fx%3D1. Without a session, it answers401 Unauthorizedwith a page that says to sign in to the console first. - The edge role takes the code at
/__hopbox/auth, and trades it for a token withEdgeService.ExchangeMachineCode. It sets the token in the cookie__Host-hopbox_machine, and answers303 See Otherto the path. A path that is not a plain path on the host, such as//other.example, becomes/. - The browser asks for
https://box1.example.com/page?x=1with the machine cookie. The edge role checks the token withEdgeService.AuthorizeMachineRequest, takes the cookie out of the request, and forwards the request to the machine.
The code never reaches the machine. The answers of steps 2 and 3 carry Cache-Control: no-store and Referrer-Policy: no-referrer.
| Item | Value |
|---|---|
| Code | 32 random bytes in base64url, 43 characters. The control store keeps only its SHA-256. |
| Code lifetime | 60 s, one use, and only for the machine that it names. |
| Codes of one session | At most 30 in a minute. The next one gets 429 Too Many Requests. |
| Token | 32 random bytes in base64url. The control store keeps only its SHA-256. A new token of the same browser and machine replaces the older one. |
| Token lifetime | The life of the console session that made it: 7 days without a use, and 30 days at most. A sign-out ends it at once, and so does a suspend of the account, which deletes its sessions (the admin API). Each check of a token keeps its session alive, as a call of the console does. |
| Cookie | __Host-hopbox_machine=<token>; Path=/; Secure; HttpOnly; SameSite=Lax. The cookie is host-only, and it has no Max-Age. When the browser closes, it drops the cookie. |
| Kept answers | The edge role keeps each answer that allows a token on a machine. It keeps an answer for at most 1 minute, and never past the end of the console session. It keeps no refusal, so a new grant works at once. It keeps at most 10,000 answers. When it is full, it starts again empty. |
The control role tells the edge servers about each change that can end an access. A change event of a machine, such as an unshare or a delete, is about that machine. An event edge.access_changed is about every machine (Control store tables). A sign-out, a member that leaves an org or that an admin removes, and a deleted account publish it. A suspension of an account or of an org publishes it too. A change can arrive while an edge server has no channel. So each new control channel also brings a change of every machine.
At a change, the edge role drops the answers that it keeps for the machines of the change. It also checks each open request of their private URLs again in the background, such as a WebSocket or a long download. A token that lost its access ends its open requests at once. The edge role also checks every open request again each minute, because a console session can end by time, without a change event. So an open request never keeps an access for more than about a minute after its end.
Answers of a private URL
Section titled “Answers of a private URL”| Case | Answer |
|---|---|
A top-level navigation by GET or HEAD without a valid machine cookie |
303 See Other to /auth/machine (step 1) |
| Any other request without a valid machine cookie | 401 Unauthorized. A browser does not follow a redirect for these, so the page says to open the URL in a browser first. |
A request from a page of another origin, other than a top-level navigation by GET or HEAD |
401 Unauthorized. It counts as a request without a machine cookie (Requests of other sites). |
A WebSocket upgrade whose Origin is not the machine host |
403 Forbidden |
| Two different machine cookies | It counts as a request without a machine cookie. The edge role sets one machine cookie on a host, so it cannot tell which one it set. |
| A token that names no live sign-in, such as after a sign-out | The edge role clears the machine cookie with Max-Age=0, and starts the sign-in again. |
| The account has no access to the machine now | 403 Forbidden |
| The org of the machine is suspended | 403 Forbidden |
| A code that is unknown, used, expired, or for another machine | 403 Forbidden with a page that says to open the URL again |
| The control role does not answer | 502 Bad Gateway |
Requests of other sites
Section titled “Requests of other sites”The machine hosts of an install share one site, such as example.com. A browser sends a SameSite=Lax cookie with each request inside a site. Without a check, a page of box1 can send a fetch, a form POST, or a WebSocket to box2. The browser then adds the machine cookie of box2. So the code of one machine can act in the private URL of another account. The edge role reads the fetch metadata of the browser:
-
A request with
Sec-Fetch-Site: same-siteorcross-sitecounts as a request without a machine cookie. Only a top-level navigation passes:GETorHEADwithSec-Fetch-Mode: navigate, andSec-Fetch-Dest: documentor noSec-Fetch-Dest. A link from another page then still opens the URL. A frame in a page of another machine hasSec-Fetch-Dest: iframe, so it shows the URL without the cookie. -
A WebSocket upgrade needs no
Origin, or the originhttps://<machine host>. A browser always sends the origin of its page with a WebSocket. -
/__hopbox/authtakes only a top-level navigation byGET. A request with anotherSec-Fetch-Modegets405 Method Not Allowed, so a page cannot plant a cookie with a code of its own. -
A prefetch or a prerender of speculation rules is no navigation, because no person asked for it. Chromium sends it with the headers of a navigation,
Sec-Fetch-Site: noneorsame-site, and the Lax cookie. The headerSec-Purpose, or the olderPurpose, names it withprefetchorprerender. Such a request counts as a request without a machine cookie, and it starts no sign-in. So a page of a machine cannot use up the codes of a person or write in the name of that person. Chromium names the prefetch that a machine page makes of its own pagesnonetoo, so that prefetch gets401, and only speed changes, because the real click works. Safari sends noSec-Purpose, and MDN records speculation rules prefetch in Safari 26.2 behind a preference. If Safari turns that on by default without the header, this rule does not hold there.
A request from the page of the machine itself has Sec-Fetch-Site: same-origin, and uses the cookie. A client without fetch metadata, such as curl, also uses it.
Answers of /auth/machine
Section titled “Answers of /auth/machine”GET /auth/machine is a plain HTTP endpoint of the public API on the domain of the install, outside of the Connect chain. Its parameters are machine, the name of the machine, and path, the path to return to. A path that is not a plain path on the host becomes /.
| Case | Status |
|---|---|
| A code | 303 See Other to the machine host (step 2) |
| No live console session | 401 Unauthorized |
| An account that uses no such machine, or no such machine | 404 Not Found |
| An account that sees the machine, but does not use it, such as an org admin on a private machine of another member | 403 Forbidden |
| More than 30 codes of the session in a minute | 429 Too Many Requests |
| The org of the machine is suspended, or the install has no domain | 409 Conflict |
| A request that is not a top-level navigation, such as a prefetch, a frame, or a fetch | 403 Forbidden, and no code |
The answer is a plain text page with the reason and the request ID.
The Grafana host
Section titled “The Grafana host”The host grafana.<domain> serves Grafana to an instance admin. The wildcard certificate and the wildcard DNS record of the install already cover the host, so no certificate, DNS record, or port changes. The owner decided the host in Q162 of the abuse plan.
The edge role keeps no sign-in state for this host. It forwards each request to a control server, over the same mTLS connection as the API, with Hopbox-Forward-Target: grafana. It deletes any value of that header that a client sent, on each host. The control role trusts the header under the same proof as Hopbox-Client-Addr (Listeners). The API listener on 127.0.0.1:7080 does not serve this host. A separate host keeps Grafana out of the console origin, so a script bug in Grafana cannot use the console session.
If a machine holds the name grafana, it keeps its URL, and the host serves that machine. No new machine takes the name (Domain rules). While a machine holds the name, /auth/grafana answers 409 Conflict, so a browser never carries a code to machine code. A rename or a delete ends the route of the machine, and the host then serves Grafana. This is Q165.
The sign-in takes the steps of a private machine URL, on the control role. The dashboard is hopbox-overview.
- A browser asks for
https://grafana.example.com/d/hopbox-overviewwithout a cookie. The handler answers303 See Othertohttps://example.com/auth/grafana?path=%2Fd%2Fhopbox-overview. A path longer than 512 characters becomes/. - Unless the request has
Sec-Fetch-Site: same-origin,/auth/grafanaanswers with a page that holds one link, and it writes nothing (The page with one link). A click on the link comes back to this step. The control role reads the session cookie of the console at/auth/grafana. With the session of an instance admin whose sign-in is at most 1 hour old, it makes a one-time code, and answers303 See Othertohttps://grafana.example.com/__hopbox/auth?code=<code>&path=%2Fd%2Fhopbox-overview. - The handler takes the code at
/__hopbox/auth, trades it for a token in one transaction, writes the audit entrygrafana.open, sets the cookie__Host-hopbox_grafana, and answers303 See Otherto the path. A path off the list of Paths of the host becomes/. The code never reaches Grafana. - The handler reads the session in the control store on each later request, and forwards the request to
127.0.0.1:3000with a signed token.
The check runs on each request and keeps no answer, because a revoke of an instance admin deletes a row and sends no event. So a revoke, a sign-out, a suspend, and a new sign-in act at the next request. A forwarded request has a bound of 2 minutes. Grafana Live is off and the handler refuses each Upgrade, so no request stays open past a revoke. Numbers already on the screen stay until the tab closes.
| Item | Value |
|---|---|
| Code | 32 random bytes in base64url. The control store keeps only its SHA-256. It works once, for 60 s. |
| Codes of one session | At most 30 in a minute, also when the browser trades each one, and for requests at the same time. The next one gets 429 Too Many Requests. So the audit log gets at most 30 entries grafana.open in a minute from one session. An open waits at most 2 s for another open of its session, and then gets 429 Too Many Requests too. |
| Token | 32 random bytes in base64url. The control store keeps only its SHA-256 in grafana_sessions (Control store tables). A new token of the same browser replaces the older one. |
| Token lifetime | The shortest of three: 1 hour after the sign-in, the end of the console session, and the delete of the row. A use of Grafana does not extend the hour. Each allowed request keeps the session alive, as a call of the console does. |
| Cookie | __Host-hopbox_grafana=<token>; Path=/; Secure; HttpOnly; SameSite=Lax. It is host-only and has no Max-Age. It opens only this host. No API call takes it, and the edge role drops it toward a machine. |
| Who opens it | Policy action grafana.open: the console session of an instance admin with a sign-in at most 1 hour old. An admin key, a CLI token, and local root use the SSH tunnel. Admin API calls keep their 10 minutes (Sessions, cookies, and sign-in links). |
Answers of /auth/grafana
Section titled “Answers of /auth/grafana”GET /auth/grafana is a plain HTTP endpoint of the public API on the domain of the install, outside of the Connect chain. Its parameter is path.
| Case | Answer |
|---|---|
| No live session | 303 See Other to /signin?return_to=/admin/overview |
| A session of an account that is not an instance admin | 404 Not Found |
| An instance admin whose sign-in is more than 1 hour old | 303 See Other to /signin?again=1&return_to=/admin/overview |
A machine holds the name grafana, or the install has no domain |
409 Conflict |
| More than 30 codes of the session in a minute | 429 Too Many Requests |
A request that is not a top-level navigation by GET, such as a prefetch of a page of a machine |
403 Forbidden, and no code |
A navigation with Sec-Fetch-Site: none, same-site, or cross-site |
200 OK with a page that holds one link, and no code and no audit entry |
A navigation with no Sec-Fetch-Site |
403 Forbidden, with text that says the browser is too old and names the SSH tunnel. No code and no audit entry. |
| Maintenance mode | 503 Service Unavailable, because a code is a write |
| The control store does not answer | 503 Service Unavailable, with text that names the SSH tunnel. It logs the sign-in of the Grafana host failed. |
The console follows its return path with a client-side navigation, so a sign-in ends in the Admin area. The admin then opens the link of Grafana again.
The page with one link
Section titled “The page with one link”A page of a machine can start a real navigation with a script and stop it at once, and the server acts before the stop. It can also go back in its history to a page that redirects, and that request looks like a typed address. So /auth/grafana makes a code only for a click on the domain of the install. This is Q170 of the abuse plan. Links from anywhere still work with one click, so Q167 stays.
Sec-Fetch-Site |
Answer |
|---|---|
same-origin |
The sign-in goes on. The links of the Admin area and the link of the page send it. |
none, same-site, cross-site, or any other value |
The page with one link, and no code and no audit entry, whatever Sec-Fetch-User says |
| No value | 403 Forbidden, with text that says the browser is too old for this host and names the SSH tunnel. No code, no audit entry, and no link. |
Sec-Fetch-User decides nothing here. In Chromium, a script gets Sec-Fetch-Site: none with Sec-Fetch-User: ?1 with no click or key, through history.back() and a redirect. So the server cannot tell such a request from a typed address.
| How a browser arrives | What it takes |
|---|---|
| A link in the Admin area | One click. The link goes straight to /auth/grafana on the domain, with its path. |
| A live cookie of the host, on any host path | No page. Grafana opens. |
| A typed address, a bookmark, or a link from another site, without a live cookie of the host | The page, then one click |
| The host without a cookie, or with a cookie of an ended session | A redirect to /auth/grafana, the page, then one click. The click goes on to the path that the browser asked for. |
The page holds one plain link to the same sign-in, with its path escaped. Its headers are Cache-Control: no-store, X-Frame-Options: DENY, Referrer-Policy: no-referrer, Cross-Origin-Opener-Policy: same-origin, and a policy of default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'. So a frame gets 403, a window that a script opens gives that script no handle on the page, and no script runs on it.
As far as the tests show, an audit entry grafana.open means a click on the domain of the install. The tests ran in Chromium only. A page on the domain is the console, so a script bug in the console can still send such a request. The console refuses a return_to value under /auth/, because any page can set that value. Before this rule, the console followed such a value with a navigation in the page, and a reload of that page sent same-origin and made a code. No real flow returns to such a path.
/auth/machine has no such page. The backlog holds that question.
Answers of the host
Section titled “Answers of the host”| Case | A navigation | Any other request |
|---|---|---|
| No cookie, two different cookies, or a request from another site (Requests of other sites) | 303 See Other to /auth/grafana |
403 Forbidden with JSON |
| A token with no live session, after a sign-out, a suspend, or a new sign-in | The handler clears the cookie, and answers 303 See Other to /auth/grafana |
403 Forbidden with JSON. The cookie stays. |
| An account that lost the role | The handler clears the cookie, and answers 404 Not Found |
404 Not Found with JSON. The cookie stays. |
| A sign-in more than 1 hour old | 303 See Other to /auth/grafana. That step reads the console session. An old one goes to the sign-in, and a new one gets a code that replaces the cookie. So a cookie of an older session never holds the browser on the sign-in page. |
403 Forbidden with JSON and the text this page needs a sign-in within the last hour |
| A path off the list | 303 See Other to / |
403 Forbidden with JSON |
A POST whose Origin is not the origin of the host, or an Upgrade |
Does not apply | 403 Forbidden with JSON |
| A body of more than 4 MiB | Does not apply | 413 Content Too Large with JSON |
| No private key on this control server, or a key file that does not work, such as one that its group can read | 404 Not Found with text that names the guide. The log holds the reason for a key file that does not work. |
The same |
| Grafana does not answer | 502 Bad Gateway with text that names the SSH tunnel. It logs Grafana did not answer. |
The same |
Grafana answers with a redirect to /login, because it refused the signed identity |
502 Bad Gateway with text that says to restart grafana-server, and that names the SSH tunnel. It logs Grafana refused the identity of hopboxd. |
The same |
| The control store does not answer | 503 Service Unavailable with text that names the SSH tunnel. It logs reading a sign-in of the Grafana host failed. |
The same |
| A code that is unknown, used, or expired | 403 Forbidden with a page that says to open the host again |
405 Method Not Allowed |
| A failed trade, for example a failed write of its audit entry | 503 Service Unavailable with text that names the SSH tunnel. It logs trading a code of the Grafana host failed. |
405 Method Not Allowed |
Only a navigation clears the cookie. The answer to a fetch can arrive after a trade set a new cookie, and a clear then ends the new one. A dead token does nothing, and the next trade replaces it.
The sign-in runs first, so a person without the role cannot tell whether an install has Grafana. Maintenance mode stops a code and a trade, but not a live token, because the check only reads. A tab that opened before maintenance mode works until its hour ends.
A top-level navigation from any site works, also from a page of a machine, as for a private machine URL. With a live cookie of the host it opens Grafana, and without one it takes the click of the page with one link. The list of paths applies to it. This is Q167.
A code is not bound to a browser. An instance admin can send a link with a code to another instance admin. The browser of the other admin then uses the session of the first, and the audit log names the first. Both hold the role, and all admins share one Viewer, so no access changes. An account without the role cannot get a code. A fix needs a state cookie on the host, and it does not cover a link straight to /auth/grafana, so this limit stays.
Each refusal goes to the log as grafana refused, with the reason, the method, the path, the client address, the request ID, and the account and the session when a token named them. A refusal writes no audit entry. A file that holds a wrong key logs the key of the identity toward Grafana does not work. The log and the audit log never hold the cookie, the code, the signed token, the key, the query string, or the body. The audit entry holds the path without its query, or / for a path that looks like a credential.
What Grafana gets
Section titled “What Grafana gets”The handler deletes Cookie and Authorization from the request, and sets X-Hopbox-Identity over any value that a client sent. The header holds a signed Ed25519 token with the claims iss (hopboxd), sub (hopbox), iat, and exp, which is 120 s later. The handler reuses a token for 60 s. The private key is the file grafana-identity.key next to the bootstrap config, and Grafana holds only the public key (hopboxd). hopboxd refuses a key file that its group or others can read.
All instance admins share one Grafana user, hopbox, which is always a Viewer. A Viewer can run any PromQL through /api/ds/query, so a stolen cookie reads all metrics and can send heavy queries. It reaches nothing else in Grafana.
The handler removes each Set-Cookie of Grafana, because a Grafana bug must not set a cookie on the whole domain. It adds these headers to each answer of Grafana. Cache-Control: no-store applies outside /public/.
| Header | Value |
|---|---|
Content-Security-Policy, as a second header |
default-src 'self'; connect-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline' blob:; font-src 'self'; frame-src 'none'; frame-ancestors 'none'; object-src 'none'; worker-src 'self' blob:; script-src 'self', plus the nonce that the policy of Grafana names for its page. So an inline script without that nonce does not run. The policy stops a fetch, a beacon, a stylesheet, an image, a font, a <link rel=prefetch>, and the request of a frame. It does not close the page. A script bug can still send data in four ways: with a speculation rule that holds the nonce of the page, with RTCPeerConnection, in the TLS handshake of a blocked frame, and with a top-level navigation. |
X-Frame-Options |
DENY |
X-Content-Type-Options |
nosniff |
Referrer-Policy |
no-referrer |
Cross-Origin-Opener-Policy |
same-origin |
Cross-Origin-Resource-Policy |
same-origin |
Cache-Control |
no-store |
Paths of the host
Section titled “Paths of the host”The list applies at the root of the host. A path with an escaped byte, a backslash, //, or a dot segment never passes, because Grafana had a path traversal bug through such a path (CVE-2025-4123). Each new Grafana version can change this list. If it does, the browser test of the host fails.
| Method | Paths |
|---|---|
GET, HEAD |
/, /dashboards, /d/hopbox-*, /d/hopbox-*/<slug>, the .js, .css, .svg, .png, and .woff2 files under /public/build/, /public/fonts/, /public/img/, and /public/plugins/prometheus/, /api/annotations, /api/plugins/prometheus/settings, /api/search, /api/teams/search, /api/prometheus/grafana/api/v1/rules, /api/alertmanager/grafana/api/v2/alerts, /api/user, /api/user/orgs, /api/user/teams, and the reads of the /apis/ groups dashboard, folder, iam, collections, preferences, provisioning, quotas, and userstorage that the dashboards use |
POST |
/api/ds/query, /ofrep/v1/evaluate/flags, /api/frontend-metrics, and the user-storage path of /apis/userstorage.grafana.app/ |
The browser test proves that the dashboards need these parts of /public/. The pages under /public/views/ and /public/emails/ run an inline script and have no policy of Grafana, so the list leaves them out. It also leaves out each .html file and /public/mockServiceWorker.js.
Everything else is blocked, among others /login, /logout, /metrics, /admin/*, /explore, /render/*, /api/datasources*, /api/admin/*, /api/live/*, /api/org*, /api/snapshots, /api/dashboards/*, and each PUT, PATCH, and DELETE. /__hopbox/ belongs to the handler. The POST of user-storage and of /api/frontend-metrics lets the shared user keep a page history, and a stolen cookie can change that history. This is Q168.
The SSH tunnel
Section titled “The SSH tunnel”The tunnel stays the way in when hopboxd is down, because it uses Grafana’s own login form and depends on no part of hopboxd. See Monitor an install with Prometheus and Grafana.
The public IPv6 address
Section titled “The public IPv6 address”An edge server can hold one floating IPv6 address on its uplink, as the owner decided on 2026-10-27 (rule 4 of the bastion architecture, plan question Q94). The bootstrap config names it in edge.public_ipv6, without a prefix length (the bootstrap config of hopboxd):
[edge]public_ipv6 = "2001:db8::11"The zone names this address in its AAAA records, through the public addresses of the install (the DNS role, hopbox Terraform provider). Without a floating IPv6 address, the zone has no AAAA record, and the install takes IPv4 only.
The operator routes the address to the server at its provider. The network setup of the Terraform provider puts it on the uplink as a /128 (hopbox Terraform provider). Without the Terraform provider, put it there by hand. hopboxd puts it on the uplink whenever no interface of the server holds it, also at its first start when the address was never there (The check of the uplink). The host firewall has no rule of its own for it. The uplink is in the public zone, so the address takes the public ports of the edge server from every source (the host firewall). The NAT66 of the machines never takes it (the host firewall).
The egress of the machines
Section titled “The egress of the machines”Each edge server that enrolls takes the egress of the machines of the nodes through its egress tunnel hbe0 (the egress of the machines). Its host firewall forwards the IPv4 egress to the public zone, and the IPv6 egress to the uplink alone (the host firewall). The IPv4 egress gets the source edge.public_ipv4, the floating address of the edge server (the bootstrap config of hopboxd). The IPv6 egress gets a global IPv6 address of the uplink (NAT66), never the floating address of edge.public_ipv6. Without such an uplink address, the edge server refuses the IPv6 egress (the egress of the machines). An edge server with the node role is the local exit of its own machines (the egress of the machines). While its uplink has no IPv4 default route on a device with a carrier, the edge server takes no egress of the nodes (the egress of the machines).
The source of the own connections
Section titled “The source of the own connections”The other servers of an install take the traffic of the install only from the peer addresses (the host firewall). An edge server also holds floating addresses on its uplink. A connection of the edge server from a floating address reaches no port of another server. So hopboxd binds these connections of each server to its peer address:
- the control channel and its data streams, to the internal listener of a control server (the control channel),
- the enrollment of
hopboxd enrollandhopboxd install --enroll-token(Enrollment and the install PKI), - the requests that the edge role forwards to the internal listeners (Forwarded requests),
- the data streams that a control process forwards to another control process (the control channel).
The peer address is the one address of the set peers of the host firewall that an interface of the server holds. hopboxd run takes the set of its host firewall. hopboxd enroll and hopboxd install take the last sets in <data_dir>/hostfw/peers (the host firewall). In these cases, a connection leaves from the source that the kernel picks:
- The server has no sets yet, such as at its first enrollment. The network setup of the Terraform provider runs before that enrollment, and sets the source of the default route, so the enrollment still leaves from the peer address.
- No interface of the server holds an address of
peers, or more than one interface address is inpeers. - The destination is not a peer address, such as loopback, a vRack address, or a host name.
The other connections of the server leave from the source that the kernel picks. These include the SSH of an operator from the edge server to a node (the host firewall), the mesh, and the egress tunnels. The kernel takes the preferred source (src) of the default route. Without it, on an uplink with /32 addresses and an onlink gateway, the kernel takes the first address of the uplink, and that can be a floating address. So the network setup of an edge server with floating addresses sets src <peer address> on the default route of the uplink.
This is a build default of the fix of docket item 137, not an owner decision.
The check of the uplink
Section titled “The check of the uplink”A DHCP renew, networkctl reconfigure, or ifdown and ifup of the uplink can drop the source of the default route and the floating addresses. On an edge server with edge.public_ipv4, edge.floating_addresses, or edge.public_ipv6 (the bootstrap config of hopboxd), the unit channel of hopboxd run checks the uplink at its start, after each change of an address or a route of the server, and every 2 s. The uplink is the device of the IPv4 default route of the main table with the lowest metric. A check repairs these gaps:
- If the default route has another preferred source or none, the check sets the peer address as its source. It keeps the gateway, the metric, the protocol, the flags, and the MTU of the route. This also works while the uplink has no carrier.
- If no interface of the server holds an address of
edge.public_ipv4,edge.floating_addresses, oredge.public_ipv6, the check puts that address on the uplink, as a/32or a/128. The first check after a start also puts on an address that the uplink never held.
The check logs each repair at level warn (the egress of the machines). It never removes an address or a route. It does not know a floating address that the bootstrap config does not name, so it does not put such an address back. Before the first sets of the control plane, the check does not know the peer address, so it does not change the route. An edge server without the three keys gets no check.
The Terraform provider puts the floating addresses on the uplink at each boot and at each apply. It writes edge.floating_addresses only to a release whose version names the feature floating-addresses (the version command). When an update drops a floating address, the provider first writes the new keys and waits for the restart of hopboxd, and only then removes the address from the uplink. Otherwise the check puts the address back at once (hopbox Terraform provider).
To see the state of the uplink, run these commands on the edge server. The default route must show src and the peer address, and the uplink must hold each floating address:
ip -4 route show defaultip addr show dev <uplink>| Test | Where it runs | What it checks |
|---|---|---|
The tests of internal/peersrc and internal/egress without root |
make test, also on a Mac |
The pick of the peer address, the dials that bind to it, and a check of the uplink with a fake kernel: the repairs, a floating address on another device, an unknown peer address, and a failure that logs once. |
TestEdgeSourceStaysOnThePeerAddress of internal/egress |
make test-linux, as root in a privileged container |
An edge server whose uplink holds its floating address before its peer address, each as a /32, with an onlink gateway and no source on the default route. A plain dial leaves from the floating address. A dial of hopboxd to a peer leaves from the peer address. A check sets the source of the route and puts back the lost floating addresses, two IPv4 and one IPv6, and keeps an address that it did not set. The route keeps its gateway, protocol, metric, onlink flag, and MTU, and a default route of another device with the same metric stays. After the check, a plain dial leaves from the peer address. The check also sets the source while the uplink has no carrier. |
TestEdgeServers of test/fleet |
make test-fleet |
A real hopboxd on an edge server sets the source of its default route, and puts back the source and its floating IPv6 address after a loss. |
EdgeService
Section titled “EdgeService”hopbox.cluster.v1.EdgeService serves the edge servers on the internal listener (the internal listener). Every call needs the certificate of a server with the edge role. Another server gets permission_denied.
| Call | Request | Response | Errors |
|---|---|---|---|
ExchangeMachineCode |
machine: the name of the machine of the host. code: the code of the query. |
token: the value of the machine cookie. |
unauthenticated for a code that is unknown, used, expired, malformed, or for another machine. invalid_argument for a name that breaks the name rules. |
AuthorizeMachineRequest |
machine: the name of the machine of the host. token: the value of the machine cookie. read_only: true for a check that serves no request of the machine, such as the reason on the page of a failed wake. It then keeps the console session as it is. A control process of an older release reads it as false. |
machine_id and account_id, UUIDs. valid_for: how long the edge can keep the answer, at most 1 minute. |
unauthenticated for a token that is unknown, malformed, for another machine, or of an ended console session. permission_denied for an account without access. failed_precondition for a suspended org. |
AuthorizeSSH |
ssh_port, public_key, linux_user, and client_ip of an SSH connection, and recheck for a check of an open connection (the SSH front door). Each allowed sign-in writes the audit entry machine.ssh. |
machine_id, machine_name, account_id, and valid_for. |
permission_denied for every key, port, or user that opens nothing, with one message. invalid_argument for a sign-in without a valid client_ip, with the message invalid argument: a sign-in needs the IP address of the SSH client or invalid argument: the client IP is not an IP address. |
The edge role calls each one with a timeout of 10 s.
EdgeService.WakeForConnection
Section titled “EdgeService.WakeForConnection”hopbox.cluster.v1.EdgeService.WakeForConnection resumes a machine in standby, or wakes a hibernated machine, for a connection that passed its check of access at the edge (Wake on connect). It needs the certificate of a server with the edge role. The edge role calls it only after the check of access of the connection, so it carries no credential of the client. It sets the target running with the actor system, and does not wait. The edge role waits for the target in the routes.
| Request field | Type | Meaning |
|---|---|---|
machine_id |
string | The ID of the machine of the route, a UUID. |
channel |
WakeChannel |
The kind of the connection: WAKE_CHANNEL_SSH for an SSH key that the front door accepted, WAKE_CHANNEL_PRIVATE_URL for a signed-in request of a private URL, or WAKE_CHANNEL_PUBLIC_URL for a request of a public URL. The audit entry records it in its detail channel, as ssh, private_url, or public_url. |
| Response field | Type | Meaning |
|---|---|---|
current_state |
string | The state of the machine at the call, such as hibernated. |
A machine with the target standby resumes, with the checks of ResumeMachine. A machine with the target hibernated wakes, with the checks of WakeMachine: the limits of the org, the room of its node, and a node whose heartbeats name the feature and the capability (the machine API). Each change writes the audit entry machine.resume or machine.wake with the actor system, and counts as a use of the machine. A machine whose target is running already gives no change, no audit entry, and no error. A private machine whose creator is suspended never resumes or wakes, because a route knows only the suspension of the org.
| Error | Code |
|---|---|
| A caller without the edge role | permission_denied |
A machine_id that is not a UUID, or a channel that is not one of the three |
invalid_argument |
| No machine has the ID | not_found |
| A suspended org, a private machine of a suspended creator, a node without the feature, or a machine with the target stopped | failed_precondition. The message names the reason, such as the machine box1 is stopped, so a connection does not start it. Start it with: hopbox machine start box1. |
| An org limit, or a node without room | resource_exhausted. The message names the limit or the room. |
Metrics
Section titled “Metrics”The edge role serves these metrics on the metrics listener of hopboxd (Metrics).
| Metric | Type | Labels | Meaning |
|---|---|---|---|
hopbox_edge_requests_total |
counter | to: api, machine, redirect, or refused |
The HTTP requests of the edge role, by where they went. api holds the requests of the domain and of the Grafana host. A redirect goes to HTTPS, to a sign-in, or back from a sign-in. A refusal got a page of the edge role, also a refusal past the bounds of open requests. |
hopbox_edge_tls_refusals_total |
counter | reason: no_sni, unknown_host, or no_certificate |
The TLS handshakes that the edge role refused. |
hopbox_edge_client_connection_refusals_total |
counter | listener: https or http. bound: client or network |
The connections that the edge role closed at once. client: their IPv4 address or IPv6 /64 held 256 open connections on the listener. network: their IPv6 /48 held 1,024. |
hopbox_edge_open_connections |
gauge | listener: https or http |
The connections that the listener holds now. |
hopbox_edge_connection_limit |
gauge | listener: https or http |
The most connections that the listener holds at once: 16,384 for https, and 65,536 for http. A connection past it waits in the backlog of the kernel. |
hopbox_edge_routes |
gauge | none | The machines that the routes name. |
hopbox_edge_certificate_not_after_seconds |
gauge | none | The end of the certificate that the edge role serves, in seconds since the Unix epoch, or 0 before the first certificate. |
hopbox_edge_machine_requests_total |
counter | visibility: public or private. status_class: 1xx, 2xx, 3xx, 4xx, or 5xx |
The HTTP requests that the edge role forwarded to a machine, by the visibility of the machine URL and the class of the status of the answer. A forward that failed counts as 5xx, because the edge answers it with 502. A request whose client left before the answer does not count. A request that the edge answers itself, such as a stopped machine, counts only in hopbox_edge_requests_total. Each of the 10 series starts at 0. |
hopbox_edge_upstream_errors_total |
counter | reason: not_running, no_address, no_answer, expired_lease, or waking |
The 502 and 503 answers to the requests of a machine URL, by cause. not_running: the route has no target, because the machine does not run, or the control role holds no live route record of it. no_address: the machine runs without an address on its node. no_answer: the machine did not answer on its URL port, a 502. expired_lease: the lease of the target ended at the edge, because its node did not confirm the machine lately. waking: a held request whose machine did not wake (Wake on connect). A request whose client left before the answer does not count. Each of the 5 series starts at 0. |
hopbox_edge_wakes_total |
counter | result: woken, refused, failed, timeout, error, or node_busy |
The resumes and wakes that the edge role started for connections, by result. Connections at once to one machine share one wake, and a request that gets a kept refusal starts none. woken: the routes gave the machine a target. refused: the control role refused it, such as for a limit. failed: the machine failed, stopped, or went away. timeout: no target within 30 s. error: the control role did not answer. node_busy: no slot of the wakes of its node freed within the hold, so the wake never reached the control role. Each of the 6 series starts at 0. |
hopbox_edge_wake_wait_seconds |
histogram | protocol: http or ssh |
The time from the first packet of a connection to a sleeping machine to the first answer of the machine: the header of its HTTP answer, or the end of the SSH handshake with its OpenSSH server. Only a connection that waited for a wake counts. The buckets end at 30 s, the hold of a connection. |
hopbox_edge_held_connections |
gauge | protocol: http or ssh |
The connections that the edge role holds now until their sleeping machine runs. |
hopbox_edge_expired_targets |
gauge | none | The targets of the routes whose lease ended at the edge, read at each scrape. A node that stopped its heartbeats leaves its targets here until the control role pushes new routes. |
The metrics of the SSH front door start with hopbox_edge_ssh_ (the SSH front door).
The edge role logs with component=edge.
| Message | Level | When |
|---|---|---|
edge listening |
info | The listeners are open, with https and http. |
serving a certificate |
info | A new certificate, with domain, not_after, and serial. |
serving the machine URLs of a domain |
info | The first routes, or the routes of a new domain, with domain and machines. |
forwarding a request to the control plane failed |
warn | A forwarded request failed, with path and err. |
forwarding a request to a machine failed |
info | A machine did not answer, with host and err. |
checking a machine URL sign-in failed |
warn | AuthorizeMachineRequest failed without an answer, with machine and err. |
trading a machine URL code failed |
warn | ExchangeMachineCode failed without an answer, with machine and err. |
ended the open requests of a machine URL sign-in that lost its access |
info | A check refused a token with open requests. The fields are machine, open_requests, and code. |
ended the open requests of machine URLs that changed |
info | New routes ended open requests, with open_requests (Machine URLs). |
waking a machine for a connection |
info | The control role took a wake for a held connection, with machine, name, channel, and state (Wake on connect). |
the wake of a machine for a connection ended |
info | The wait of the edge for the target ended, with machine, result, and after. |
the control plane refused the wake of a machine for a connection |
info | WakeForConnection refused the wake, with machine and err. |
asking the control plane for the wake of a machine failed |
warn | WakeForConnection failed without an answer, with machine and err. |
The host firewall logs the uplink of the IPv6 egress with component=hostfw (the host firewall). The check of the uplink logs with component=egress (the egress of the machines).
The edge role can refuse a certificate or routes that the control role pushed. The agent of the control channel then logs the edge role refused a push of the control plane, and keeps what it has at error level, with push and err.
Not in phase 1
Section titled “Not in phase 1”These parts of the edge role come later:
- The wake rule for a connection to a raw port (Q196 of the phase 3 plan, phase 4).
- Subdomain routes, such as
sub.box1.example.com(phase 4). - Custom domains and org domains (phase 4).
- Raw TCP and UDP ports (phase 4).