fossasia / visdom

A flexible tool for creating, organizing, and sharing visualizations of live, rich data. Supports Torch and Numpy.
Apache License 2.0
10.05k stars 1.13k forks source link

Visdom does not display when accessed via a proxy (with a path in its URL) #666

Open nebilbenmabrouk opened 5 years ago

nebilbenmabrouk commented 5 years ago

Bug Description I want to access visdom only via a proxy.

Visdom runs at the address 'http://visdomHost:8097' The proxy runs at the address 'http://proxyHost:8080/path1'. It receives requests at this address and redirects them to visdom.

The issue is that visdom cannot find static files because it does not consider/support the proxy path ('/path1'). In the browser console, I see that visdom is looking for the files 'http://proxyHost:8080/static/css/xxx', whereas the correct address is 'http://proxyHost:8080/path1/static/css/xxx'

How can I configure visdom to consider the path in the proxy URL.

Note that the proxy works fine when the path is simply '/'.

Thanks in advance.

Reproduction Steps

  1. Run visdom
  2. Configure a proxy (with a PATH in its URL) to redirect requests to visdom. For instance, you can configure nginx to redirect the path '/path1' to visdom.
  3. See the errors that appear in the browser console
JackUrb commented 5 years ago

Hi @nebilbenmabrouk - thanks for filing. Proxy setups can get quite complicated and I don't intend to explore covering all of them. For this specific case though you may be able to use the -base_url path1 command line arg when starting the server. (You May also have to start accessing http://visdomhost:8097/path1 though, I'm not entirely sure)

nebilbenmabrouk commented 5 years ago

Hi @JackUrb, Thank you for your answer. I tried to apply your suggestion but I faced two issues:

First, when I change the base_url to '/path1' instead of '/', the websocket connection does not work (I see the red button 'offline') and in the browser I find this error: WebSocket connection to 'ws://localhost:8097/path1/socket' failed: Error during WebSocket handshake: Unexpected response code: 200

Second, this solution is not applicable when the path is not static, which means it contains dynamic parameters. For example, when I go to the proxy address http://proxyHost:8080/services/{id}/ the proxy redirects me to the visdom service. The {id} is a dynamic parameter, that we cannot know in advance at the time of starting visdom.

I suggest (if possible) to consider the whole URL of the proxy (including the path) and not only its host and port.

Thanks

JackUrb commented 5 years ago

Sorry that didn't work out quite right. Feel free to investigate a solution to this further; I unfortunately won't have any bandwidth in the near future to dive deeper into proxy setups, but if you come across something I'd be happy to incorporate it.