Documentation
¶
Overview ¶
Package proxy implements HTTP reverse proxying to workspace pods. It handles routing requests to specific workspace containers, supporting both standard HTTP requests and WebSocket upgrades for terminal access and other real-time communication.
Package proxy provides a reverse proxy for workspace services running in-cluster. It supports HTTP and WebSocket connections, with Location header rewriting for redirects. Proxy behavior is configurable per-image via ProxyConfig.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(opts *HandlerOptions) http.Handler
Handler returns an http.Handler that proxies requests to workspace services. URL pattern: /proxy/{namespace}/{name}/{rest...} Proxies to: http://{name}.{namespace}.svc.cluster.local:80/{rest...}
Supports WebSocket upgrade transparently via httputil.ReverseProxy. Applies per-image proxy configuration when available.
func ShouldRewriteAbsolutePaths ¶
func ShouldRewriteAbsolutePaths(lookup ConfigLookup, imageRefs []string) bool
ShouldRewriteAbsolutePaths checks if any image in the registry needs Referer-based absolute path rewriting.
func ShouldServeNoOpSW ¶
func ShouldServeNoOpSW(lookup ConfigLookup, imageRefs []string) bool
ShouldServeNoOpSW checks if any image in the registry needs a no-op ServiceWorker. Used to decide whether to serve /sw.js at the root level.
Types ¶
type Config ¶
type Config struct {
// NeedsNoOpSW: serve a no-op ServiceWorker at /sw.js to prevent SW registration errors.
NeedsNoOpSW bool
// WebSocketPaths: paths that use WebSocket (informational — all paths support WS transparently).
WebSocketPaths []string
// RewriteHostAbsolutePaths: rewrite requests with absolute paths that escape the proxy
// prefix by using the Referer header to determine the target workspace.
RewriteHostAbsolutePaths bool
// CustomRequestHeaders: additional headers to inject into proxied requests.
CustomRequestHeaders map[string]string
// InjectBaseTag: inject a <base> tag into HTML responses (not yet implemented).
InjectBaseTag bool
// TLSInsecure: connect to backend over HTTPS with skip-verify (for self-signed certs).
TLSInsecure bool
}
Config holds proxy behavior hints for a specific workspace image.
type ConfigLookup ¶
ConfigLookup is a function that returns the proxy config for a given workspace image string. Returns nil if no specific config is found (default behavior applies).
type HandlerOptions ¶
type HandlerOptions struct {
// ConfigLookup returns proxy config for a given image reference.
ConfigLookup ConfigLookup
// WorkspaceImageLookup returns the image reference for a workspace by ns/name.
WorkspaceImageLookup WorkspaceImageLookup
// ExternalHost is the external hostname (e.g. "workspaces.example.com") that
// clients use to reach this service. When set, it is forwarded as the Host
// header to backend services so they generate correct remoteAuthority values.
ExternalHost string
}
HandlerOptions configures the proxy handler.
type WorkspaceImageLookup ¶
WorkspaceImageLookup is a function that returns the container image for a workspace given its namespace and name. Returns empty string if not found.