Get Proxy URL and Port from Handler

#1

I’m doing some work on the SAMLAuthenticator, and I need to craft an XML document that lets a service know where a user needs to POST some data. From what I understand, this means that the handler for this specific request will need to know the URL and port that the Jupyter proxy is listening to. How would I figure out where the proxy was listening (assuming it’s configured in JupyterHub) from a Request Handler?

#2

You can get the host+port of the current request with self.request.host which will look like hostname:port (if there’s no port given, you can use self.request.protocol to pick 80 for http or 443 for https). This is the host+port of the client’s request, so it will be the public hostname/port of the application.

1 Like