Documentation
¶
Overview ¶
Package proxy runs a NetBird proxy server. It attempts to do everything it needs to do within the context of a single request to the server to try to reduce the amount of concurrency coordination that is required. However, it does run two additional routines in an error group for handling updates from the management server and running a separate HTTP server to handle ACME HTTP-01 challenges (if configured).
Index ¶
- func ParseTrustedProxies(raw string) ([]netip.Prefix, error)
- type Server
- func (s *Server) ListenAndServe(ctx context.Context, addr string) (err error)
- func (s *Server) NotifyCertificateIssued(ctx context.Context, accountID types.AccountID, serviceID types.ServiceID, ...) error
- func (s *Server) NotifyStatus(ctx context.Context, accountID types.AccountID, serviceID types.ServiceID, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseTrustedProxies ¶
ParseTrustedProxies parses a comma-separated list of CIDR prefixes or bare IPs into a slice of netip.Prefix values suitable for trusted proxy configuration. Bare IPs are converted to single-host prefixes (/32 or /128).
Types ¶
type Server ¶
type Server struct {
ID string
Logger *log.Logger
Version string
ProxyURL string
ManagementAddress string
CertificateDirectory string
CertificateFile string
CertificateKeyFile string
GenerateACMECertificates bool
ACMEChallengeAddress string
ACMEDirectory string
// ACMEEABKID is the External Account Binding Key ID for CAs that require EAB (e.g., ZeroSSL).
ACMEEABKID string
// ACMEEABHMACKey is the External Account Binding HMAC key (base64 URL-encoded) for CAs that require EAB.
ACMEEABHMACKey string
// ACMEChallengeType specifies the ACME challenge type: "http-01" or "tls-alpn-01".
// Defaults to "tls-alpn-01" if not specified.
ACMEChallengeType string
// CertLockMethod controls how ACME certificate locks are coordinated
// across replicas. Default: CertLockAuto (detect environment).
CertLockMethod acme.CertLockMethod
// WildcardCertDir is an optional directory containing wildcard certificate
// pairs (<name>.crt / <name>.key). Wildcard patterns are extracted from
// the certificates' SAN lists. Matching domains use these static certs
// instead of ACME.
WildcardCertDir string
// DebugEndpointEnabled enables the debug HTTP endpoint.
DebugEndpointEnabled bool
// DebugEndpointAddress is the address for the debug HTTP endpoint (default: ":8444").
DebugEndpointAddress string
// HealthAddress is the address for the health probe endpoint.
HealthAddress string
// ProxyToken is the access token for authenticating with the management server.
ProxyToken string
// ForwardedProto overrides the X-Forwarded-Proto value sent to backends.
// Valid values: "auto" (detect from TLS), "http", "https".
ForwardedProto string
// TrustedProxies is a list of IP prefixes for trusted upstream proxies.
// When set, forwarding headers from these sources are preserved and
// appended to instead of being stripped.
TrustedProxies []netip.Prefix
// WireguardPort is the port for the NetBird tunnel interface. Use 0
// for a random OS-assigned port. A fixed port only works with
// single-account deployments; multiple accounts will fail to bind
// the same port.
WireguardPort uint16
// ProxyProtocol enables PROXY protocol (v1/v2) on TCP listeners.
// When enabled, the real client IP is extracted from the PROXY header
// sent by upstream L4 proxies that support PROXY protocol.
ProxyProtocol bool
PreSharedKey string
// SupportsCustomPorts indicates whether the proxy can bind arbitrary
// ports for TCP/UDP/TLS services.
SupportsCustomPorts bool
// RequireSubdomain indicates whether a subdomain label is required
// in front of this proxy's cluster domain. When true, accounts cannot
// create services on the bare cluster domain.
RequireSubdomain bool
// MaxDialTimeout caps the per-service backend dial timeout.
// When the API sends a timeout, it is clamped to this value.
// When the API sends no timeout, this value is used as the default.
// Zero means no cap (the proxy honors whatever management sends).
MaxDialTimeout time.Duration
// GeoDataDir is the directory containing GeoLite2 MMDB files for
// country-based access restrictions. Empty disables geo lookups.
GeoDataDir string
// MaxSessionIdleTimeout caps the per-service session idle timeout.
// Zero means no cap (the proxy honors whatever management sends).
// Set via NB_PROXY_MAX_SESSION_IDLE_TIMEOUT for shared deployments.
MaxSessionIdleTimeout time.Duration
// contains filtered or unexported fields
}
func (*Server) ListenAndServe ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth contains exported proxy auth values.
|
Package auth contains exported proxy auth values. |
|
cmd
|
|
|
proxy
command
|
|
|
internal
|
|
|
certwatch
Package certwatch watches TLS certificate files on disk and provides a hot-reloading GetCertificate callback for tls.Config.
|
Package certwatch watches TLS certificate files on disk and provides a hot-reloading GetCertificate callback for tls.Config. |
|
debug
Package debug provides HTTP debug endpoints and CLI client for the proxy server.
|
Package debug provides HTTP debug endpoints and CLI client for the proxy server. |
|
flock
Package flock provides best-effort advisory file locking using flock(2).
|
Package flock provides best-effort advisory file locking using flock(2). |
|
geolocation
Package geolocation provides IP-to-country lookups using MaxMind GeoLite2 databases.
|
Package geolocation provides IP-to-country lookups using MaxMind GeoLite2 databases. |
|
grpc
Package grpc provides gRPC utilities for the proxy client.
|
Package grpc provides gRPC utilities for the proxy client. |
|
health
Package health provides health probes for the proxy server.
|
Package health provides health probes for the proxy server. |
|
k8s
Package k8s provides a lightweight Kubernetes API client for coordination Leases.
|
Package k8s provides a lightweight Kubernetes API client for coordination Leases. |
|
restrict
Package restrict provides connection-level access control based on IP CIDR ranges and geolocation (country codes).
|
Package restrict provides connection-level access control based on IP CIDR ranges and geolocation (country codes). |
|
types
Package types defines common types used across the proxy package.
|
Package types defines common types used across the proxy package. |
Click to show internal directories.
Click to hide internal directories.