Skip to content

Commit ee7c6c2

Browse files
committed
make api endpoint configurable, restore previous entrypoint names
1 parent 6ec4d5b commit ee7c6c2

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

jupyterhub_traefik_proxy/proxy.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _add_port(self, proposal):
198198
traefik_entrypoint = Unicode(
199199
help="""The traefik entrypoint name to use.
200200
201-
By default, will be `web` if http or `websecure` if https.
201+
By default, will be `http` if http or `https` if https.
202202
203203
If running traefik externally with your own specified entrypoint name,
204204
set this value.
@@ -210,9 +210,19 @@ def _add_port(self, proposal):
210210
def _default_traefik_entrypoint(self):
211211
"""Find the traefik entrypoint that matches our :attrib:`self.public_url`"""
212212
if self.is_https:
213-
return "websecure"
213+
return "https"
214214
else:
215-
return "web"
215+
return "http"
216+
217+
traefik_api_entrypoint = Unicode(
218+
"auth_api",
219+
help="""The traefik entrypoint name to use for API access.
220+
221+
Separate from traefik_entrypoint,
222+
because this is usually only on localhost.
223+
""",
224+
config=True,
225+
)
216226

217227
@default("traefik_api_password")
218228
def _warn_empty_password(self):
@@ -415,7 +425,7 @@ async def _setup_traefik_static_config(self):
415425
self.traefik_entrypoint: {
416426
"address": urlparse(self.public_url).netloc,
417427
},
418-
"enter_api": {
428+
self.traefik_api_entrypoint: {
419429
"address": urlparse(self.traefik_api_url).netloc,
420430
},
421431
}
@@ -444,7 +454,7 @@ async def _setup_traefik_dynamic_config(self):
444454
routers = http.setdefault("routers", {})
445455
routers["route_api"] = {
446456
"rule": f"Host(`{api_url.hostname}`) && PathPrefix(`{api_path}`)",
447-
"entryPoints": ["enter_api"],
457+
"entryPoints": [self.traefik_api_entrypoint],
448458
"service": "api@internal",
449459
"middlewares": ["auth_api"],
450460
}

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ def _launch_traefik_cli(*extra_args, env=None):
379379
"--api",
380380
"--log.level=debug",
381381
"--providers.providersThrottleDuration=0s",
382-
# "--entrypoints.web.address=:8000",
383-
"--entrypoints.websecure.address=:8000",
384-
"--entrypoints.enter_api.address=:8099",
382+
# "--entrypoints.http.address=:8000",
383+
"--entrypoints.https.address=:8000",
384+
"--entrypoints.auth_api.address=:8099",
385385
)
386386
args = default_args + extra_args
387387
return _launch_traefik(*args, env=env)

0 commit comments

Comments
 (0)