SSL/WS proxy: HTTP(S) to HTTPS WebSocket bridge for Kasm workspaces.
Environment variables:
TARGET_HOST(default:localhost) - Target host to proxy requests toTARGET_PORT(default:6901) - Default target port for proxied requestsLISTEN_PORT(default:8000) - Port for kasmproxy to listen onVNC_PW(optional) - VNC password for HTTP basic auth (empty username, VNC_PW as password)
Requests to /ssh (and all sub-paths like /ssh/, /ssh/test, and queries like /ssh?param=value) are automatically routed to port 9999 with basic HTTP auth if VNC_PW is set.
Examples:
/ssh→ routes tolocalhost:9999/ssh/ssh/→ routes tolocalhost:9999/ssh//ssh/nested/path→ routes tolocalhost:9999/ssh/nested/path/ssh?id=123→ routes tolocalhost:9999/ssh?id=123
Requests to /files and /api routes are routed to port 9998 for the file manager service:
/files→ routes tolocalhost:9998/files(HTML page)/files/→ routes tolocalhost:9998/files/(HTML page)/files?test=1→ routes tolocalhost:9998/files?test=1(HTML page with query)
Asset requests under /files are transformed to root paths on upstream:
/files/js/app.js→ routes tolocalhost:9998/js/app.js(JavaScript asset)/files/css/style.css→ routes tolocalhost:9998/css/style.css(CSS asset)/files/images/logo.png→ routes tolocalhost:9998/images/logo.png(Image asset)/files/webfonts/font.woff→ routes tolocalhost:9998/webfonts/font.woff(Font asset)
API requests route to port 9998 for file manager operations:
/api/→ routes tolocalhost:9998/api/(API endpoint list)/api/options?type=GET_SHOW_ALL_FILES→ routes tolocalhost:9998/api/options?type=GET_SHOW_ALL_FILES(API call)
All other paths route to the default TARGET_PORT:
/→ routes tolocalhost:6901/(KasmVNC)- Any other path not matching above routes
If VNC_PW environment variable is set, HTTP Basic Authentication is automatically added to:
- All
/sshrequests - All
/filesrequests - All
/apirequests - Uses username
kasm_userwithVNC_PWas the password (credentials:kasm_user:VNC_PW)
The auth header is only added if the incoming request doesn't already have authorization.
- Both HTTP and WebSocket handlers implement the same routing and path transformation logic
- Host headers are dynamically updated based on the target port
- Path matching is precise:
path === '/path' || path.startsWith('/path/') || path.startsWith('/path?') - Cached credentials from successful HTTP requests are reused for WebSocket auth
- Upstream protocol selection is dynamic per-port:
- Port 9999 (/ssh): HTTP protocol
- Port 9998 (/files, /api): HTTP protocol
- Port 6901 (kasmvnc) and others: HTTPS protocol
- HTML response body rewriting for
/filesroute:- Relative asset paths (src/href) are rewritten to include the proxy path prefix
- Asset directory requests (
/files/js/,/files/css/,/files/images/,/files/webfonts/) strip the/filesprefix to get root-relative upstream paths - Only HTML content-type responses are rewritten; other content passes through unchanged