Clientless Access to LLM APIs via Reverse Proxy
Updated
You run an API inside your network, for example a self-hosted LLM API, and a third party, such as a customer or a partner, needs to call it from their own systems. They cannot install the NetBird client on those systems, and you do not want to open ports 80 or 443 on your firewall to reach the API host.
This guide shows how to publish the API with the NetBird Reverse Proxy. The third party calls a fixed HTTPS URL and sends an access token in a request header on every call. The proxy checks the token and forwards only requests with the right token through the NetBird tunnel to your API.
What You'll Achieve
Caller's system ──► NetBird proxy ──► NetBird tunnel ──► llm-server
(no NetBird, (HTTPS URL, (peer, API on
X-Access-Token) checks the token) port 8080)
After following this guide, the third party can call the paths under /v1/ at https://llm-api.<base-domain> with the header X-Access-Token. A request with a missing or wrong token gets 401 from the proxy, and a request to any other path gets 403. Neither reaches your API. The API host connects out to NetBird and accepts no inbound connections from the internet.
Two Ways to Reach the API
The proxy can reach your API in two ways:

- Via a NetBird peer. The API host runs the NetBird client. This guide uses this way.
- Via a network resource. Your API host does not run the NetBird client. A routing peer, a NetBird peer on the same LAN, forwards the traffic to it. Before Step 2, create a Network with the API host as a resource and that peer as its routing peer.
Only Step 2 differs: there you select the resource instead of the peer.
When Not to Use This
- The caller can run the NetBird client. Enroll their system as a peer instead. A peer gets identity-based access policies and per-peer audit, which a shared token cannot provide.
- The callers are your own AI agents or developer tools such as coding assistants. Use NetBird's Agent Network rather than a plain peer. Each caller must run the NetBird client. It reaches LLM APIs over the tunnel with an identity from your identity provider, so you get per-identity policies, LLM usage and cost limits, and audit logs, with no shared secret.
- The callers are people in a browser. Use SSO authentication on the service, so each person signs in as themselves.
- You need to know which caller made a request. The token is a shared secret. The access log records the source address and that a request used header authentication, not which token or which person sent it.
Example Setup
The steps use these values. Replace them with your own.
| Item | Example value |
|---|---|
| API host, running the NetBird client | llm-server |
| API on that host | plain HTTP on port 8080 |
| Path prefix the third party may call | /v1/ |
| Service subdomain | llm-api |
| Token header | X-Access-Token |
| Third party's egress IP range | 203.0.113.0/24 |
Prerequisites
- A NetBird user with the
OwnerorAdminrole.Network Adminand other roles cannot create or change Reverse Proxy services: see the permissions matrix. - The NetBird client installed and connected on the API host. The host needs outbound internet access only. If the host cannot run the client, make it a resource in a Network with a routing peer.
- The path prefix the third party needs, for example
/v1/on an OpenAI-compatible API. In Step 2 you open only that prefix and block the rest of your API, for example the/api/endpoints that download or delete models on an Ollama server. - Self-hosted only: at least one proxy instance connected to your management server, and every proxy instance on v0.81.0 or later. An older instance ignores the Block access target from Step 2 and forwards every path, even when your other instances block it. See Self-hosted proxy setup.
- Optional: the fixed public IP ranges the third party's systems call from. Ask the third party for them. In Step 4 you add a rule that allows only those ranges, so a leaked token does not work from any other address. If the third party has no fixed ranges, for example callers in many locations, you skip that rule and the token is the only gate.
Step 1: Generate a Token
You create the token, a long random secret, and give it to the third party. The third party sends it in the X-Access-Token header, and the proxy forwards only requests with this exact value.
Generate the token on your own machine:
openssl rand -hex 32
Keep the output for Steps 3 and 5. NetBird stores only a hash of the value and never shows it again, so save it in your secret manager now.
Use the generated value as it is, not a word or a short code.
Step 2: Enter the Service Details
- In the dashboard, go to Networking > Reverse Proxy > Services and click Add Service. A dialog with four tabs opens. You fill in its tabs in Steps 2 to 4, and nothing is saved until you click the dialog's own Add Service button at the end of Step 4.
- On the Service tab, enter the subdomain
llm-apiand select a base domain. The subdomain and base domain together form the URL you give the third party. - Leave Service Type on HTTPS Service.
- Click Add Target. In the Add Target dialog, click the selector at the top, open the Peers tab and select
llm-server. If the API host is a network resource, select it on the Resources tab. - Leave the protocol on
http://and set Port to8080. - In Location, enter the path prefix the third party may call, here
/v1/. Start and end it with a slash, for example/api/v2/for another API. Location matches by prefix, so/v1would also match/v1beta. - Turn on Preserve Full Path, which appears once Location is filled in, and click Add Target at the bottom of the dialog. With it off, the proxy removes
/v1/and the limit no longer holds. - Block every other path. Click Add Target again and select the same peer and port. Set Location to
/, expand Optional Settings, set Access to Block access, and click Add Target.
Do not skip action 8. A /v1/ target on its own does not limit the service to /v1/.
To open a second prefix, repeat actions 4 to 7 with that prefix. To open your whole API, leave Location empty in action 6, skip actions 7 and 8, and click Add Target at the bottom of the dialog. The third request in Step 5 and the bullet about /v1/ in Step 6 then do not apply.
Step 3: Require the Token
- Switch to the Authentication tab.
- Next to HTTP Headers, click Add.
- The type list shows Basic Auth. Change it to Custom Header.
- In Name, enter
X-Access-Token. In Value, paste the token from Step 1. - Click Add Headers. HTTP Headers now shows Enabled.
If the third party's software has only an API key setting and cannot add custom headers, choose Bearer Token instead of Custom Header in action 3 and paste the token. The third party then enters the token as their API key, and their software sends it as Authorization: Bearer <token>. The proxy checks that header and removes it before forwarding, as it does with X-Access-Token. The rest of this guide uses X-Access-Token. If you chose Bearer Token, send -H "Authorization: Bearer $TOKEN" in this guide's curl commands instead.
Do not add SSO, Password or PIN Code. A request that passes any enabled method gets in, so each extra method is another way past the token.
Step 4: Restrict Source Addresses and Create the Service
Add Service on the Advanced Settings tab creates the service and puts its URL online. Before you click it, check that HTTP Headers on the Authentication tab shows Enabled. A service created with no authentication method lets anyone with the URL call your API.
If the third party calls from fixed IP ranges, allow only those ranges.
- Switch to the Access Control tab and click Add Rule.
- In the new rule, keep Allow Only, change the second list from Country to CIDR Block, and enter the third party's IP range, for example
203.0.113.0/24. For a second range, click Add Rule again. - Switch to the Advanced Settings tab and click Add Service.
A request from an address outside those IP ranges gets 403, even with the right token.
If the third party has no fixed IP ranges, add no rule: go straight to Advanced Settings and click Add Service. The token is then the only gate.
Step 5: Verify
The new service shows Issuing certificate... and then Setting up service... in the service list, each for a few seconds. Wait until both messages are gone before you send a request.
Check the service before you hand anything over. If you added rules in Step 4 and your own address is not in them, every request returns 403. To test from your own address, click the ⋮ menu at the end of the service's row, click Edit, add an Allow Only rule of type CIDR Block for your address (for example 198.51.100.7/32) on the Access Control tab, and click Save Changes. Remove that rule the same way after this step.
Set the URL and the token in your shell. Replace <base-domain> with your base domain, angle brackets included, and keep the quotes. The read command shows nothing while it waits: paste the token from Step 1 and press Enter. Entering the token this way keeps it out of your shell history:
export API_URL="https://llm-api.<base-domain>"
read -rs TOKEN
Run three requests. The first, with no token, must get 401. The second, with the token, must return your API's normal answer. The third, to a path outside /v1/, must get 403:
curl -i "$API_URL/v1/models"
curl -i -H "X-Access-Token: $TOKEN" "$API_URL/v1/models"
curl -i -H "X-Access-Token: $TOKEN" "$API_URL/"
/v1/models is an example path: use a path your API serves under your prefix. If the second request also gets 401, look at the response body. The body Unauthorized comes from the proxy: the token you entered does not match the one saved in Step 3. An HTML page from NetBird, as for the first request, means no token was sent: $TOKEN is empty, so run read -rs TOKEN again. Any other 401 comes from your API: an API that checks a key of its own needs that key in the target's Custom Headers (see Optional Settings on the Target). If the first request returns your API's response instead of 401, HTTP Headers is not enabled. Click Edit in the service's ⋮ menu, redo Step 3, and click Save Changes. If the third request returns anything other than 403, the target on / is missing or not set to Block access: add it as in Step 2, action 8. Then run all three requests again before you share the URL.
Step 6: Hand Over the URL and Token
Send the third party the URL and the token over a channel you trust for secrets. They add one header to every request:
curl -H "X-Access-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"model":"my-model","messages":[{"role":"user","content":"Hello"}]}' \
"$API_URL/v1/chat/completions"
Replace my-model with a model your API serves. Many LLM servers, for example Ollama, accept requests in this OpenAI format.
Tell the third party four things:
- Send the header on every request. There is no login and no session. A request without the header gets
401, even straight after a successful one. - Send the token exactly as given. The header name is not case-sensitive, but the token must match exactly. With
X-Access-Token, send the token alone, with no prefix such asBearer. With Bearer Token, the third party enters only the token and their software adds the prefix. - Call only paths under
/v1/. Any other path gets403. - Call the HTTPS URL. An
http://request gets only a redirect, so scripts must usehttps://.
What the Proxy Does with a Request
- The token never reaches your API. The proxy removes
X-Access-Tokenfrom the request before it forwards it. - Streaming and slow answers pass through. The proxy sends each streamed chunk on as it arrives and by default sets no limit on how long an answer may take, so server-sent events and answers that take minutes to start both work.
- TLS ends at the proxy. The proxy terminates HTTPS, reads the request, and forwards it inside the encrypted NetBird tunnel to the API host. If the API host is a network resource, the tunnel ends at the routing peer, and the request travels from there to the API host over your LAN as plain HTTP.
Optional Settings on the Target
In the service list, click the arrow at the start of the service's row, click Edit on the target row below it, and expand Optional Settings. Save Changes in that dialog saves the target at once.
- Request Timeout. Set a value such as
10s. If the proxy cannot connect to your API within that time, it answers504, and the caller is not left waiting. If the connection is refused, for example because the API is not running, the proxy answers502at once. The timeout covers connecting to your API, not the length of the answer, so it does not cut long responses. - Custom Headers. Use this when your API checks a key of its own, for example an LLM server that requires an API key, and you do not want to give that key to the third party. Add a header such as
Authorizationwith the valueBearer <your API key>. The proxy adds it to every request it forwards to your API and replaces anAuthorizationheader the third party sent. The third party then holds only the token from Step 1, which the proxy checks, and never sees your API's key. Custom Headers are not the HTTP Headers entry from Step 3: that entry checks requests coming in, and Custom Headers are added to requests going out to your API. If your API has no key of its own, leave Custom Headers empty.
Changing or Revoking the Token
- Rotate: generate a new token as in Step 1, send it to the third party, and agree a switch time. At that time, click Edit in the service's ⋮ menu. On the Authentication tab, click Edit next to HTTP Headers, paste the new token into Value over the hidden one. If you chose Bearer Token in Step 3, enter
Bearer <new token>there instead: the wordBearer, a space, then the new token. When you edit an entry, the dashboard saves Value exactly as you enter it and does not add the prefix as it did when you created the entry. Click Save, then Save Changes. The proxy switches to the new token as soon as it receives the change and then refuses the old one. Then run the Step 5 checks again: a request with the new token must reach your API, and a request with the old token must get401with the bodyUnauthorized. Do not treat the old token as revoked until that check returns401. If the token leaked, do this as soon as possible. - Revoke: click Disable or Delete in the service's ⋮ menu. A disabled service gives no HTTP answer: the caller's connection fails. Enable in the same menu turns it back on. Removing only the
X-Access-Tokenentry leaves the service running with no token check.
More Than One Third Party
Create one service per third party. Each third party then has their own URL, token, access control rules and access log, and you can revoke one without touching the others.
Security Boundaries
- The token is the caller's whole identity. Anyone who holds it, and calls from an allowed address, is let through. Treat it like a password and rotate it when anyone who knew it, on either side, leaves.
- Publishing a service is itself an access grant. Your access control policies do not govern traffic from the proxy to
llm-server: a published service is reachable even if no policy allows it. Review the service list on the Reverse Proxy page as part of any access audit.
Summary
The third party's system sends X-Access-Token with every request to https://llm-api.<base-domain>. The proxy accepts requests only from the allowed IP ranges, if you set any (here 203.0.113.0/24), refuses every path outside /v1/, checks the token, removes it, and carries the request through the NetBird tunnel to port 8080 on llm-server. The API host needs no inbound port open to the internet.

