[client,management] Add --with-target-host to netbird expose
Describe your changes
netbird expose only targets the local peer. The new --with-target-host flag takes an IP or hostname the exposing peer can reach (a Docker service name, a LAN host, a peer IP), and the service is created with that host as its target. Without the flag nothing changes.
The host travels in a new additive target_host field on the daemon and management ExposeServiceRequest messages and is validated in the CLI and in management. The proxy target keeps TargetType=peer with the exposing peer as TargetId, so existing expose permission checks still apply. Schemes, ports, paths and loopback addresses are rejected.
Verified locally: go test -race passes for ./client/internal/expose, ./shared/management/client, ./management/internals/shared/grpc, ./management/internals/modules/reverseproxy/service/... and the new client/cmd expose tests; go vet, gofmt and make lint (new-from-rev) are clean; client and management build.
Issue ticket number and link
Closes #5777
Stack
Checklist
- Is it a bug fix
- Is a typo/documentation fix
- Is a feature enhancement
- It is a refactor
- Created tests that fail without the change (if possible)
- I ran and tested this change locally — I did not rely on CI to find out whether it works
- This PR has a single purpose (not a fix + refactor + feature in one)
- This change is a trivial fix, OR it links an issue the NetBird team agreed on beforehand. Changes to the public API, gRPC protocols, functionality behavior, CLI / service flags, or new features always need that agreement first. See CONTRIBUTING.md.
By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.
Documentation
Select exactly one:
- I added/updated documentation for this change
- Documentation is not needed for this change (explain why)
The flag is self-documented in netbird expose --help with an example. I can follow up with the CLI reference and reverse-proxy pages in netbirdio/docs once the flag shape is agreed.
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
N/A
Demo

Summary by CodeRabbit
- New Features
- Expose a service using a specified target hostname or IP address. Valid hosts are normalized, and the selected target is shown with the local port when the service is ready.
- Bug Fixes
- Requested target hosts are carried through to the service configuration and preserved when peer address information is refreshed.
- Proxy connections to loopback destinations are blocked.
- Invalid target hosts, including loopback addresses and names, are rejected.