Skip to content

How to put Dask Dashboard behind web server like reverse proxy? #2073

Closed

Description

@h4nyu

I am planning on putting dash dashboard behind Nginx at particular url. However the http request of dashboard is abosolute url. so i am wondering if i can i set hostname or relative url.

Activity

  1. mrocklin commented on Jun 25, 2018

    @mrocklin
    Member

    Can you say a bit more about how you would normally do this without Dask, and if there are any challenges that Dask introduces in particular?

  2. h4nyu commented on Jun 26, 2018

    @h4nyu
    Author

    My application is container based. I have multiple web service like the figure below.
    in prior to dask, I used luigi as workflow engine and luigi web ui was servered by using reverse proxy at /luigi.
    Compare to luigi, i think dask is more easier to define computation graph
    and to test. So that was the reason i tried to replace luigi to dask.

    screen shot 2018-06-26 at 7 48 04 pm
    Problem is all href in 'a' tag is started with '/' .
    screen shot 2018-06-26 at 9 06 22 pm
    Other pages are functioning well

  3. mrocklin commented on Jun 26, 2018

    @mrocklin
    Member
  4. h4nyu commented on Jun 26, 2018

    @h4nyu
    Author

    screen shot 2018-06-26 at 9 49 28 pm

  5. mrocklin commented on Jun 26, 2018

    @mrocklin
    Member
  6. h4nyu commented on Jun 26, 2018

    @h4nyu
    Author

    yes, correct.

  7. mrocklin commented on Jun 26, 2018

    @mrocklin
    Member
  8. h4nyu commented on Jun 26, 2018

    @h4nyu
    Author

    command is dask-scheduler --bokeh-prefix=dask-dashboard ?
    I got 404.

  9. mrocklin commented on Jun 26, 2018

    @mrocklin
    Member
  10. h4nyu commented on Jun 26, 2018

    @h4nyu
    Author

    i used
    dask-scheduler --bokeh-prefix=dask-dashboard

    and changed nginx.conf

            location ~ ^/dask-dashboard/ {
    -           rewrite ^/dask-dashboard(/.*)$ $1 break;  
                proxy_pass http://dask-scheduler:8787;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
            }
    

    I can acess http://192.168.10.7/dask-dashboard/status !
    It works!

    However i found href is '/dask-dashboard/status' its start with '/'.

    When multistage reverse proxy like '/foo.com/segment/..../dask-dashboard',
    dask-dasboard don't know how proxy in front of exists.

    if prefix and not prefix.startswith('/'):
    prefix = '/' + prefix

    this code is forced to set prefix as absolute path.
    I am wondering if can i set relative path to --bokeh-prefix like ./dash-dashboard .

  11. mrocklin commented on Jun 26, 2018

    @mrocklin
    Member
  12. jakirkham commented on Jun 27, 2018

    @jakirkham
    Member

    FWIW was just playing around with nbserverproxy to do something similar (which works great I might add), but ran into the same issue with paths being incorrect on the main page as it appears to be the case here. Though they were correct in the header links of the individual apps. Would be interested in fixing this to be relative paths if you can give me a pointer about where to look and what might need to be done.

  13. vishnu2kmohan commented on Jun 28, 2018

    @vishnu2kmohan

    I can report that with dask-scheduler --bokeh-prefix=/daskboard (and with --bokeh-prefix=daskboard - note the lack of a leading slash) the following Nginx directive works just fine and I can access all the Active Bokeh Apps links under http(s)://<nginx>/daskboard/ just fine:

          location ^~ /daskboard/ {
              proxy_pass http://<dask-scheduler>:8787;
              proxy_set_header Host $http_host;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_http_version 1.1;
              proxy_redirect off;
              proxy_buffering off;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection $connection_upgrade;
              proxy_read_timeout 86400;
          }
    

    There is no need for the Nginx rewrite clause and I don't think we ought to remove the leading slash for the prefix in scheduler.py

    Note: Replace <dask-scheduler> with the correct hostname or IP address for your Dask Scheduler

  14. jakirkham commented on Jun 28, 2018

    @jakirkham
    Member

    Sadly the same doesn't work well for nbserverproxy as it needs to know the port the scheduler will use since this makes up the URL (e.g. it will add on /proxy/8787 assuming the default port). However we don't know the scheduler port for the dashboard unless we set it ourselves, which could still get overridden if that port is taken. Hence --bokeh-prefix is not very helpful here.

    Would much prefer the links on the Dask Dashboard menu page to be relative. This should still work well for users that set --bokeh-prefix (as they would be relative) and it would work well for users unable to set --bokeh-prefix, but needing some sort of prefix. Perhaps in the long run this would make --bokeh-prefix unnecessary as the defaults could serve all users well.

  15. mrocklin commented on Jun 28, 2018

    @mrocklin
    Member
  16. jakirkham commented on Jun 28, 2018

    @jakirkham
    Member

    Hmm...so why is it that the index listing ignores the current URL? 😕

    Yeah the navbar seems to avoid this issue. Though it doesn't include all of the apps that the index page does. Would it be worth adding them in some drop down menu on the end?

    Just to better elucidate what I'm seeing, opened issue ( #2081 ).

  17. mrocklin commented on Jun 28, 2018

    @mrocklin
    Member
  18. jakirkham commented on Jun 28, 2018

    @jakirkham
    Member

    The work stealing page is sometimes helpful. Though I agree it is mostly useful for diagnostics.

    Please see the first screen shot in issue ( #2081 ) for an example.

    So this is something that would need to be improved in Bokeh? FWIW saw they closed out issue ( bokeh/bokeh#5692 ), which seemed potentially relevant, but wasn't sure if it helped us here or how to use it.

  19. mrocklin commented on Jun 28, 2018

    @mrocklin
    Member
  20. h4nyu commented on Jul 2, 2018

    @h4nyu
    Author

    The dask-created pages all use relative links to avoid this problem entirely.

    I found absolute link in dask-created pages.

    tap = TapTool(callback=OpenURL(url='/profile?key=@name'))

    I have tested.

    -        tap = TapTool(callback=OpenURL(url='/profile?key=@name'))
    +        tap = TapTool(callback=OpenURL(url='profile?key=@name'))       
  21. mrocklin commented on Jul 2, 2018

    @mrocklin
    Member
  22. mrocklin commented on Sep 6, 2018

    @mrocklin
    Member

    If recollection serves I think that this has been resolved.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions