wetty icon indicating copy to clipboard operation
wetty copied to clipboard

Base path with trailing slash does not work

Open Warr1024 opened this issue 3 years ago • 2 comments

Describe the bug

Cannot use a base path that ends in a slash.

To Reproduce Steps to reproduce the behavior:

  1. In nginx reverse proxy, setup a /wetty/ location to redirect to WeTTY.
  2. Run WeTTY with --base /wetty/
  3. Try to load http[s]://server/wetty/ in a browser.

Expected behavior WeTTY loads and displays "username" prompt, etc.

Actual behavior WeTTY redirects from /wetty/ (root path) to /wetty (outside of the base path), missing the proxied path space. The reverse proxy will then handle the request itself, e.g. searching for a file/dir at that location, and possibly generating a redirect to re-add the trailing slash, causing a redirect loop.

Desktop (please complete the following information): N/A (irrelevant to this issue)

Smartphone (please complete the following information): N/A (irrelevant to this issue)

Web Server & Reverse Proxy

  • OpenBSD 7.1 amd64
  • nginx/1.20.2
  • nodejs v16.14.2

Additional context Allowing WeTTY access to the /wetty path (no trailing slash) is very impractical because it mismatches with all other apps hosted on the same site, and can cause inconsistent behavior with relative redirects.

Warr1024 avatar Sep 11 '22 16:09 Warr1024

FYI I am partially working around this issue for some deployments by e.g. redirecting from /wetty to /wetty/ssh/user, though it's not working for every deployment (ones affected by #395 and/or #396), and this workaround is only feasible for cases where I want to allow access only to a specific user/app rather than providing a general use terminal for any user.

Warr1024 avatar Sep 11 '22 16:09 Warr1024

The problem seems to be caused by https://github.com/butlerx/wetty/blob/main/src/server/socketServer.ts#L45. It seems as though this must have been intended to fix a problem, but I can't see an indication of what that problem was. It doesn't make sense to require a URL without a trailing slash for the base path, because if the base path is just / then there is no way to remove the trailing slash.

Warr1024 avatar Sep 11 '22 17:09 Warr1024

Stale issue message

github-actions[bot] avatar Sep 12 '23 10:09 github-actions[bot]