Jupyter-server-proxy, imported as python library, doesn't see config in jupyter_server_config.py

I’m using ProxyHandler from jupyter-server-proxy.handlers in order to proxy requests in a web server that I have built. I want to configure it to proxy to remote locations by configuring c.ServerApp.allow_remote_access = True in ~/.jupyter/jupyter_server_config.py, but it always ends up being false and jupyter-server-proxy throws a 403. I verified that jupyter-server outputs the configuration that I created when I call jupyter-server --Application.show_config=true, same for jupyter-server --ServerApp.show_config=true and jupyter-server --JupyterApp.show_config=true

Is this the right way to configure jupyter-server-proxy in this particular instance?

jupyter-server-proxy is an extension, so it has it’s own set of configuration properties, c.ServerApp.allow_remote_access only affects the jupyter-server component.

If you want jupyter-server-proxy running as a server/notebook extension to proxy remote hosts you’ll need to add the host(s) to host_allowlist, see: Accessing Arbitrary Ports or Hosts — Jupyter ServerProxy 1.0 documentation

In your title you’ve said it’s “imported as a Python library”. Can you explain a bit more, or share your code? Are you developing your own extension, or are you just importing it in a standalone script?

see this code. It’s being used to optionally integrate proxying into a web server. The code I’m talking about is actually in the dask.distributed python library.

Is it only possible to configure this by updating the host_allowlist, as in c.ServerProxy.host_allowlist = ['x']? in .jupyter/jupyter_notebook_config.py?

jupyter-server-proxy uses traitlets for configuration. Classes don’t automatically load their configuration from a file though, this has to be done explicitly.

Typically this is done in the main application, which then passes the configuration to other classes when they’re instantiated. Is this what you’re doing in dask.distributed?

If you’re not, you might be able to get away with just passing in host_allowlist=... when you construct the class:

Though from past experience things can get a bit hairy when you’re messing with traitlets derived classes. Probably no harm trying though :smiley: