Skip to content

Chat WebSocket URL missing root path in subpath proxy deployments #17249

Closed

Description

@gtritchie

Description

When RStudio Server is behind a reverse proxy at a subpath (e.g., /rstudio/ via www-root-path), the Posit Assistant chat feature fails to connect its WebSocket. The buildWebSocketUrl() function in SessionChat.cpp does not prepend the root path to the port-mapped WebSocket URL.

Steps to Reproduce

  1. Configure RStudio Server behind a reverse proxy at a subpath:
    • Set www-root-path=/rstudio in rserver.conf
    • Configure nginx (or similar) to proxy /rstudio/ to RStudio Server
  2. Open RStudio at http://host/rstudio/
  3. Open the Posit Assistant chat pane

Expected Behavior

The chat WebSocket connects to /rstudio/p/{hash}/ai-chat/ws and messages flow normally.

Actual Behavior

The chat WebSocket attempts to connect to /p/{hash}/ai-chat/ws (missing the /rstudio prefix), which causes:

  1. The request bypasses the proxy's /rstudio/ location block (404 from nginx)
  2. Even if /p/ is separately proxied, the port-token cookie is scoped to /rstudio/ so the browser doesn't send it (302 auth redirect from RStudio Server)

The chat pane loads the UI but the chat box remains disabled and icons below it don't appear.

Root Cause

buildWebSocketUrl() prepends the RS_SESSION_URL env var (for Workbench session prefixes like /s/{id}) but does not account for session-root-path. In open-source RStudio Server, RS_SESSION_URL is always empty, so the root path is never included.

Other port-mapped features (Shiny, Viewer, Plumber) are unaffected because they return relative URLs (e.g., p/08afc455/) that the browser resolves against the current page URL which already includes the subpath. The chat code differs by constructing an absolute path starting with /.

Environment

  • RStudio Server (open-source) behind nginx reverse proxy at /rstudio/
  • Ubuntu 24.04

Activity

  1. added
    new
    on Mar 19, 2026
  2. added theissue type on Mar 19, 2026
  3. added this to the Globemaster Allium milestone on Mar 19, 2026
  4. self-assigned this
    on Mar 19, 2026
  5. self-assigned this
    on Apr 14, 2026
  6. ronblum commented on Apr 14, 2026

    @ronblum
    Contributor

    Verified in RStudio Server 2026.04.0+515 on Ubuntu 24 via Firefox on Ubuntu 24.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugnewposit-ai

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions