    def init_hub(self):
        """Load the Hub URL config"""
        if self.public_url:
            # host = scheme://hostname:port (no path)
            public_host = urlunparse(urlparse(self.public_url)._replace(path=""))
        else:
            public_host = self.subdomain_host
        hub_args = dict(
            base_url=self.hub_prefix,
            routespec=self.hub_routespec,
            public_host=public_host,
            certfile=self.internal_ssl_cert,
            keyfile=self.internal_ssl_key,
            cafile=self.internal_ssl_ca,
        )
        if self.hub_bind_url:
            # ensure hub_prefix is set on bind_url
            self.hub_bind_url = urlunparse(
                urlparse(self.hub_bind_url)._replace(path=self.hub_prefix)
            )
            hub_args['bind_url'] = self.hub_bind_url
        else:
            hub_args['ip'] = self.hub_ip
            hub_args['port'] = self.hub_port

        self.hub = Hub(**hub_args)
        if self.cookie_host_prefix_enabled:
            self.hub.cookie_name = "__Host-" + self.hub.cookie_name

        if not self.subdomain_host:
            api_prefix = url_path_join(self.hub.base_url, "api/")
            if not api_prefix.startswith(self.hub.routespec):
                self.log.warning(
                    f"Hub API prefix {api_prefix} not on prefix {self.hub.routespec}. "
                    "The Hub may not receive any API requests from outside."
                )

        if self.hub_connect_ip:
            self.hub.connect_ip = self.hub_connect_ip
        if self.hub_connect_port:
            self.hub.connect_port = self.hub_connect_port
            self.log.warning(
                "JupyterHub.hub_connect_port is deprecated as of 0.9."
                " Use JupyterHub.hub_connect_url to fully specify"
                " the URL for connecting to the Hub."
            )

        if self.hub_connect_url:
            # ensure hub_prefix is on connect_url
            self.hub_connect_url = urlunparse(
                urlparse(self.hub_connect_url)._replace(path=self.hub_prefix)
            )
            self.hub.connect_url = self.hub_connect_url
        if self.internal_ssl:
            self.hub.proto = 'https'
Load the Hub URL config
jupyterhub/app.py