> For the complete documentation index, see [llms.txt](https://docs.layeronecloud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layeronecloud.com/paas/router.md).

# Replica router installation

Source project: `LayerOne` (migrated from `agents/paas-router/README.md`). Run commands from the code checkout and directory specified below, not from this documentation repository.

Install on **every machine running a connector for the platform's Cloudflare tunnel**, in the same network namespace as cloudflared. It listens only on loopback and needs outbound access to the LayerOne HTTPS feed and guest ports. This component uses only the Go standard library.

1. Run `go test ./...` and `go build -o layerone-replica-router .` in this directory on the target architecture (or cross-compile with `GOOS=linux`).
2. Install the binary at `/usr/local/bin/layerone-replica-router`. Copy the example configuration to `/etc/layerone/replica-router.json`, owned by root with mode `0600`.
3. Generate a random API key of at least 32 characters. Put the same value in the configuration file and **Settings → Application platform → Replica router API key**. The feed URL must use HTTPS. Never put the key in a URL.
4. Install `layerone-replica-router.service` under `/etc/systemd/system/`, run `systemctl daemon-reload`, then enable and start the service. Systemd passes the root-owned configuration through its credential directory to the unprivileged service.
5. Verify every connector can reach the guest network and that the service journal reports no feed errors. Only then set **Replica router origin** to `http://127.0.0.1:8780` in the platform settings. The next ingress sync sends application requests through the router. Ensure the guest firewall permits the connector host's source address.

The router refreshes its authenticated routing feed every five seconds. It round-robins requests across healthy replicas, preserves application Host headers, streams responses, and proxies WebSocket upgrades. It never retries an application request automatically. Routing stops after the feed lease expires, and probes older than 60 seconds are excluded by the feed.

To roll back routing, clear the replica router origin and sync the tunnel ingress. This restores the previous single-origin path. Scale back to one replica first if distributed traffic is required.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.layeronecloud.com/paas/router.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
