Skip to content

Change port number for JUPYTERHUB_SERVICE_URL #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ChengxuanHuang
Copy link

JupyterHub will add extensions to Jupyter ServerApp to configure some settings. It seems that newer versions of JupyterHub extensions will check the environment variable JUPYTERHUB_SERVICE_URL to determine the port and the base URL of the ServerApp and override the randomly generated port given in the batchspawner-singleuser.py file.

Therefore, I added some code to change the port of the JUPYTERHUB_SERVICE_URL variable before it is exported to the target machine. Since my setup uses base URL 0.0.0.0 (which is the default value), I do not need to change the base URL of the environment variable. Further modification might be needed to accommodate that.

@welcome
Copy link

welcome bot commented May 15, 2023

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

url = urlparse(os.environ["JUPYTERHUB_SERVICE_URL"])
url_netloc = url.netloc.split(":")

if len(url_netloc) == 2:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method of setting the port would lead to the new port not being set if the netloc in the original JUPYTERHUB_SERVICE_URL doesn't have the port explicitly defined (e.g. https://example.com/test wouldn't change). Meanwhile the solution in PR #267 for this issue does replace the port in all cases.

@timeu
Copy link

timeu commented Jan 15, 2024

What's the status of this PR ? We are running into this issue and would be great if this could be merged

@consideRatio consideRatio changed the title # Change port number for JUPYTERHUB_SERVICE_URL Change port number for JUPYTERHUB_SERVICE_URL Feb 13, 2024
@minrk
Copy link
Member

minrk commented Mar 8, 2024

merged as #267

@minrk minrk closed this Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants