Skip to content
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

Host component of bind_url should be used in dynamic rules but isn't #216

Open
Kirill888 opened this issue Jul 7, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Kirill888
Copy link

Bug description

Not sure if this is a "bug" or misunderstanding of configuration, or a missing feature to be honest.

My use case

  • Externally managed traefik proxy that handles some other services besides jupyterhub
  • External access via https with SNI (routing based on Host even when using TLS)
  • Using FileProvider, generating only dynamic rules

Dynamic routing rules generated by traefik-proxy ignore domain supplied in .public_url configuration.

Expected behaviour

I expect routing rules to include Host() component if that was configured in JupyterHub.bind_url, instead Host rule is only included when jupyterhub runs with host based routing.

If bind_url="https://example.com", I expect dynamic routing rules to be

Host(`example.com`)&&(PathPrefix(`/{ROUTESPEC}/`)||Path(`/{ROUTESPEC}`))  

Actual behaviour

generated dynamic routing rules only include PathPrefix and Path rules. Confirmed by code inspection here:

if routespec.startswith("/"):
# Path-based route, e.g. /proxy/path/
host = ""
path = routespec
else:
# Host-based routing, e.g. host.tld/proxy/path/
host, slash, path = routespec.partition("/")
path = slash + path
path_no_slash = path.rstrip("/")
path_rule = f"PathPrefix(`{path}`)"
if path_no_slash:
# include exact Path('/prefix') so that both /prefix/ and /prefix
# are served correctly
path_rule = f"( {path_rule} || Path(`{path_no_slash}`) )"
if host:
rule = f"Host(`{host}`) && {path_rule}"
else:
rule = path_rule

I think generate_rule function should take host argument extracted from .public_url configuration and if that is not empty include it in the rule.

How to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Your personal set up

  • OS:
  • Version(s):
Full environment
# paste output of `pip freeze` or `conda list` here
Configuration
# jupyterhub_config.py
Logs
@Kirill888 Kirill888 added the bug Something isn't working label Jul 7, 2023
@welcome
Copy link

welcome bot commented Jul 7, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant