Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix websocket path with server path #1745

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vsilvar
Copy link

@vsilvar vsilvar commented Jan 14, 2023

Fixes #1737 and it should work for all of the different scenarios where the relative assets also work. This includes, for example:

  • /
  • /vnc.html
  • /vnc/
  • /vnc/vnc.html

It won't work for:

  • /vnc (but the assets don't work either, so it's consistent)
  • /vnc.html/ (but this results in a 404 by default anyway)

Fixes novnc#1737 and it should work for all of the different scenarios where the relative assets also work.
This includes, for example:
   - /
   - /vnc.html
   - /vnc/
   - /vnc/vnc.html

It won't work for:
 - /vnc (but the assets don't work either, so it's consistent)
 - or /vnc.html/ (but this results in a 404 by default anyway)
app/ui.js Outdated
@@ -180,7 +180,7 @@ const UI = {
UI.initSetting('shared', true);
UI.initSetting('view_only', false);
UI.initSetting('show_dot', false);
UI.initSetting('path', 'websockify');
UI.initSetting('path', window.location.pathname.substr(1) + '/../websockify');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit roundabout way of getting to where we want¹. I'd like to see something where we construct the sane, final path and hand off here.

¹ And substr() is also deprecated. :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the usage of the deprecated substr() method.
And I agree, not sure if this is the best method, but the main idea is to get the ball rolling because this issue seems to keep being brought up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree with @vsilvar
We are facing this issue since years ago

@CendioOssman
Copy link
Member

There were some suggestions on bug #1058 that could be explored further. We don't want to hard-code any document names, though. The ideal is to mimic what the browser does when fetching linked resources.

@jginternational
Copy link

In my solution, I need several servers behind an nginx
The urls are:
www.server.com/view/user1
www.server.com/view/user2
...
The only way to get there is by adding the path as querystring
www.server.com/view/user1?path=/view/user1/websockify
www.server.com/view/user2?path=/view/user2/websockify

@dafoo
Copy link

dafoo commented Apr 20, 2023

In my solution, I need several servers behind an nginx The urls are: www.server.com/view/user1 www.server.com/view/user2 ... The only way to get there is by adding the path as querystring www.server.com/view/user1?path=/view/user1/websockify www.server.com/view/user2?path=/view/user2/websockify

A little hacky, but this worked. Thanks

@DeepCowProductions
Copy link

DeepCowProductions commented Apr 26, 2024

Could this get merged at some point?
A lot of custom application proxies don't support websocket rewrites. (also requires more configuration effort...)

For now, I am using a rather dirty fix for my docker images after the novnc installation (also works for kasmvnc):

RUN sed -i "s/UI.initSetting('path', 'websockify');/UI.initSetting('path', window.location.pathname.substring(1) + '\/..\/websockify');/" /path/to/novnc/main.bundle.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

noVNC /websockify endpoint fails when web server is served with a path prefix
5 participants