man-group / dtale

Visualizer for pandas data structures
http://alphatechadmin.pythonanywhere.com
GNU Lesser General Public License v2.1
4.72k stars 400 forks source link

Running dtale in JupyterHub and bind to localhost only #827

Closed jammann closed 10 months ago

jammann commented 10 months ago

Hi team

I'm running dtale from JupyterHub (dtale.app.JUPYTER_SERVER_PROXY = True) and everything works fine so far. I can connect through the JupyterHub proxy.

Now I wanted to bind the port (40000) to localhost ony for security reasons, because in our setup JupyterHub is running on the same server as dtale. I tried dtale.show(df, host='localhost'...) but dtale still bound to 0.0.0.0

I think this is because here https://github.com/man-group/dtale/blob/master/dtale/app.py#L854 the host argument seems to be ignored and 0.0.0.0 is hardcoded

                if USE_NGROK:
                    app.run(threaded=True, **run_kwargs)
                else:
                    app.run(
                        host="0.0.0.0",

Is there any reason for hardcoding it here? Any way to get around this?

Thanks!

aschonfeld commented 10 months ago

@jammann I believe the reason for hardcoding the flask host to 0.0.0.0 was that if you were running D-Tale on a remote server somewhere but wanted to access it from your local computer you would be able to. But from what I can tell from my testing this is not required. I will update this line of code to use the host parameter if it has been populated

aschonfeld commented 10 months ago

@jammann just released v3.8.0 to pypi (will be on conda-forge shortly) with this update. Let me know if it works. Also, if you haven't already would you mind putting your ⭐ on this repo? Thanks 🙏

jammann commented 10 months ago

Sorry, took a bit longer than expected to confirm. My installation lives behind a corporate firewall and it took some time for the PyPi repo to sync.

I can confirm that v3.8.0 behaves as I would expect. If I pass an explicit host argument to dtale.show(), it binds to that given address. When I don't pass a host argument, it binds to 0.0.0.0 as before.