memory-bank/components/ws-proxy.md
The Workspace Proxy (ws-proxy) is a specialized component in Gitpod that handles routing and proxying of HTTP and WebSocket traffic to workspaces. It acts as an intermediary between the main Gitpod proxy and individual workspace pods, providing workspace-specific routing, port forwarding, and SSH gateway functionality.
The primary purposes of the Workspace Proxy are:
The Workspace Proxy operates as a specialized proxy service with several key components:
The component is designed to efficiently route traffic to the correct workspace based on the hostname pattern, handling both HTTP and WebSocket protocols.
main.go: Entry point that calls the Execute function from the cmd packagecmd/root.go: Defines the root command and basic service configurationcmd/run.go: Implements the main proxy servicepkg/proxy/: Core proxy implementationpkg/sshproxy/: SSH gateway implementationpkg/config/: Configuration handlingpkg/analytics/: Analytics functionalitypublic/: Static assets for built-in pagescomponents/common-go:lib: Common Go utilitiescomponents/gitpod-protocol/go:lib: Gitpod protocol definitionscomponents/content-service-api/go:lib: Content service API definitionscomponents/content-service:lib: Content service clientcomponents/registry-facade-api/go:lib: Registry facade API definitionscomponents/supervisor-api/go:lib: Supervisor API definitionscomponents/ws-manager-api/go:lib: Workspace manager API definitionscomponents/server/go:lib: Server component libraryThe Workspace Proxy is configured via a JSON configuration file that includes:
The Workspace Proxy implements sophisticated routing logic:
The Workspace Proxy handles several hostname patterns:
<workspace-id>.ws.<region>.<domain><port>-<workspace-id>.ws.<region>.<domain>debug-<workspace-id>.ws.<region>.<domain>The Workspace Proxy includes an SSH gateway that allows direct SSH access to workspaces:
The Workspace Proxy integrates with:
The Workspace Proxy is typically used to: