Skip to content

Reach algod through FUNC's own origin so FUNC works behind a reverse proxy - #124

Open
EasyTiger909 wants to merge 16 commits into
GalaxyPay:devfrom
EasyTiger909:feat/same-origin-algod
Open

EasyTiger909 wants to merge 16 commits into
GalaxyPay:devfrom
EasyTiger909:feat/same-origin-algod

Conversation

@EasyTiger909

Copy link
Copy Markdown

Why

The web UI reaches algod on separate ports: 8081/8082 over HTTP, and 3537/3538 over HTTPS (where YARP picks the network from the port). So remote users must open extra ports, and FUNC can't sit behind a reverse proxy: a page served at https://func.example.lan still sends the browser to :3537/:3538, which are FUNC's own listeners with its own self-signed certificate. That also blocks the usual fix for the certificate warning, a reverse proxy with a trusted certificate. The warning matters, because WalletConnect and the copy buttons need a secure context.

What

Two new YARP routes put the network in the path, so the UI reaches algod through FUNC's own origin:

/algod/algorand/{v2,debug}/... -> http://localhost:<AlgoPort>/{v2,debug}/...
/algod/voi/{v2,debug}/...      -> http://localhost:<VoiPort>/{v2,debug}/...
  • appsettings.json: algod-v2 and algod-debug routes. {network} is constrained to algorand|voi, so anything else is a 404. The destination host is always localhost, and the port comes from FUNC's own Shared values.
  • AlgodProxy.cs (new): the existing transform, moved out of Program.cs so it can be tested. It prefers the route's network and otherwise keeps today's logic (Request.Host.Port == 3538 → Voi). It lower-cases the network because the regex route constraint is case-insensitive.
  • Web UI: a new algodBaseUrl(name) (${funcOrigin}/algod/<network>) is used by AlgodFunc, Participation.vue and Config.vue. It replaces nodeHostname(), which had no callers left. algosdk keeps the base path (covered by a test).
  • Docs: remote-access.md now needs one port (3537, or 3536) and has a "Behind a reverse proxy" section with a Caddy example. Also a changelog entry, and the README dev note.

Additive: the /v2/* and /debug/* routes, the 3537/3538 listeners and the algod ports all keep working unchanged.

Testing

  • FUNC.Tests/AlgodProxyTests.cs (no new packages): both networks reach the right stub algod, the /algod/<network> prefix is stripped, the query string is kept, unknown networks get a 404, and a legacy /v2/status with Host :3538 still goes to Voi.
  • Web UI: algodBaseUrl, AlgodFunc request URL plus token header, and error messages naming the proxied endpoint. pnpm typecheck is clean.
  • Live, on an Ubuntu box running FUNC 5.5.0 from the .deb, with Algorand on 8081 and Voi on 8080, both nodes live:
    • https://host:3537 from a LAN client: both networks work over the one port, with no connections to 3538. Logs show Voi going to 8080 and Algorand to 8081: status, the wait-for-block-after long-poll, blocks?format=msgpack, accounts, ledger, participation, and /debug/settings/config.
    • Behind Caddy (tls internal, reverse_proxy 127.0.0.1:3536, nothing else): the dashboard works for both networks with no certificate warning, and the copy buttons and WalletConnect pairing work.
  • Not tested: Windows/macOS installs, plain HTTP from the LAN with 8081/8082 closed, generating or registering a key through the new route, and an apt/NodeKit node.

Notes

  • Existing caveat: Shared.AlgoPort/VoiPort are only refreshed by Node.Get. Right after FUNC starts, before any page has loaded, /algod/voi (and :3538 today) goes to the default 8082. On a box where Voi isn't on 8082, that first request gets a 502 until the UI loads. The UI always calls Node.Get first, so it isn't affected.
  • Participation.vue's port prop is now unused.
  • Possible follow-ups, not in this PR: keying the legacy routes on Connection.LocalPort instead of the Host header, requiring a FUNC session on /algod/*, and an optional bring-your-own certificate for 3537.

acfunk and others added 15 commits September 30, 2026 09:34
fix: improve Windows service recovery and process handling
feat: external node management
Advanced dashboard, Getting Started, docs
Fix password link and override Vite dependency
Enhance diagnostics and error handling in node configuration
Add path-based YARP routes (/algod/algorand/... and /algod/voi/...) so the
web UI talks to algod through FUNC's own port. Remote access then needs a
single open port, and FUNC works behind a reverse proxy. The legacy /v2 and
/debug routes and the 3537/3538 listeners are unchanged.

- Move the proxy transform into AlgodProxy and add routing tests
- Web UI builds algod URLs with algodBaseUrl() instead of host:port
- Update remote-access docs, changelog and README dev note

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acfunk
acfunk changed the base branch from main to dev November 20, 2026 21:46
- Tell FUNC and the node apart in errors from proxied algod calls: a
  502/504 from the proxy now says the node isn't answering, and a call
  that gets no answer at all names the FUNC service instead of algod.
- Set the proxy's algod ports at startup (Node.SyncProxyPort), so
  /algod/<network> reaches a node on a non-default port before any
  page has loaded.
- Remove the unused port prop from Participation.vue.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants