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
Using a custom traefik toml file or template #543
Comments
Seconded. I'm currently restoring from a backup file each time, but it doesn't seem like the process should be that difficult. Alternately, is there a (supported) way to place some configuration values in |
Adding more context to @hMED22's issue. The problem lies in https://github.com/jupyterhub/the-littlest-jupyterhub/blob/master/tljh/traefik.py#L90 def ensure_traefik_config(state_dir):
"""Render the traefik.toml config file"""
config = load_config()
config['traefik_api']['basic_auth'] = compute_basic_auth(
config['traefik_api']['username'],
config['traefik_api']['password'],
)
with open(os.path.join(os.path.dirname(__file__), "traefik.toml.tpl")) as f:
template = Template(f.read()) The problematic line gives no way to pass the template programmatically: with open(os.path.join(os.path.dirname(__file__), "traefik.toml.tpl")) as f: |
Indeed, Can you please explain a bit what's your use-case and how would modifying Some of the config in traefik.toml has to be there for TLJH and traefik-proxy to be functional. However, I think it is possible to add an escape hatch to extend the |
I'm trying to set the [frontends]
[frontends.default]
backend = "backend__2F"
passHostHeader = true
priority = 80
[frontends.default.routes.test]
rule = "Path:/;AddPrefix:/hub"
data = "{\"hub\": true}"
[frontends.frontend__2F]
backend = "backend__2F"
passHostHeader = true
priority = 90
[frontends.frontend__2F.routes.rule1]
# rule = "PathPrefix:/hub"
rule = "Host: jupyter.example.com"
[frontends.webmo]
backend = "webmo"
passHostHeader = true
priority = 100
[frontends.webmo.routes.rule1]
# rule = "PathPrefix:/webmo"
rule = "Host: webmo.example.com"
[backends]
[backends.backend__2F]
[backends.backend__2F.servers.server1]
url = "http://127.0.0.1:15001"
[backends.webmo]
[backends.webmo.servers.server1]
url = "http://webmo.example.com:8080" I'd like to pass all addresses at I believe these rules (at least the WebMO ones) could be placed in the Traefik template file, but I'd like to try to keep within the |
AFAIK |
@GeorgianaElena yeah, an escape hatch sounds great, especially for web proxy config. Maybe something along the lines of jupyterhub/zero-to-jupyterhub-k8s#1636? |
Sure. The issues encountered serving JupyterLab static files on slow, unstable, internet connections lead us to look into two things:
We failed to enable compression at the c.JupyterHub.tornado_settings = {
'headers': {
'Content-Security-Policy': f"frame-ancestors 'self' {os.getenv('XXX_URL', '*')}",
},
'compress_response': True,
# 'gzip': True,
# We have also tried the previouly supported parameter 'gzip'
} This did not work, which lead us to enable compression at the Traefik level:
tljh overrides this with the line we feel hard codes the template file and reduces flexibility at https://github.com/jupyterhub/the-littlest-jupyterhub/blob/master/tljh/traefik.py#L90: with open(os.path.join(os.path.dirname(__file__), "traefik.toml.tpl")) as f: Is there a reason this is hard-coded? Given that the function Something like this: DEFAULT_TOML_TEMPLATE = os.path.join(os.path.dirname(__file__), "traefik.toml.tpl")
TRAEFIK_TOML_TEMPLATE = os.environ.get('TRAEFIK_TOML_TEMPLATE', DEFAULT_TOML_TEMPLATE)
def ensure_traefik_config(state_dir, traefik_toml_template=None):
...
traefik_toml_template = traefik_toml_template or TRAEFIK_TOML_TEMPLATE
with open(traefik_toml_template) as f:
template = Template(f.read())
... One way to do that according to @hMED22 is: # jupyterhub_config.py
c.TraefikTomlProxy.toml_dynamic_config_file = dynamic_conf_file_path and changing
|
I'm trying with @jhadjar to change the proxy config in
/opt/tljh/state/traefik.toml
but it is overwritten by traefik.toml.tpl every time the proxy is reloaded, is there any way to set a custom file or template to be used instead?The text was updated successfully, but these errors were encountered: