Skip to content

Commit e13fea4

Browse files
Merge pull request #192 from minrk/main
make api endpoint configurable, restore previous entrypoint names
2 parents 6ec4d5b + 26ec31b commit e13fea4

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

docs/source/consul.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ If TraefikConsulProxy is used as an externally managed service, then make sure y
161161
address = ":8000"
162162

163163
# the port on localhost where the traefik api should be found
164-
[entryPoints.enter_api]
164+
[entryPoints.auth_api]
165165
address = "localhost:8099"
166166

167167
[providers.consul]
@@ -237,7 +237,7 @@ This is an example setup for using JupyterHub and TraefikConsulProxy managed by
237237
address = ":8000"
238238

239239
# the port on localhost where the traefik api should be found
240-
[entryPoints.enter_api]
240+
[entryPoints.auth_api]
241241
address = "localhost:8099"
242242

243243
[providers.consul]

docs/source/etcd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ This is an example setup for using JupyterHub and TraefikEtcdProxy managed by an
233233
address = ":8000"
234234

235235
# the port on localhost where the traefik api should be found
236-
[entryPoints.enter_api]
236+
[entryPoints.auth_api]
237237
address = "localhost:8099"
238238

239239
[providers.etcd]

docs/source/file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ This is an example setup for using JupyterHub and TraefikFileProviderProxy manag
187187
address = ":8000"
188188

189189
# the port on localhost where the traefik api should be found
190-
[entryPoints.enter_api]
190+
[entryPoints.auth_api]
191191
address = "localhost:8099"
192192

193193
# the dynamic configuration directory

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/config_files/traefik.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ providersThrottleDuration = "0s"
1010
directory = "/tmp/jupyterhub-traefik-proxy-test"
1111
watch = true
1212

13-
[entryPoints.websecure]
13+
[entryPoints.https]
1414
address = "127.0.0.1:8000"
1515

16-
[entryPoints.enter_api]
16+
[entryPoints.auth_api]
1717
address = "127.0.0.1:8099"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
put traefik/http/middlewares/auth_api/basicAuth/users/0 "api_admin:$apr1$eS/j3kum$q/X2khsIEG/bBGsteP.x./"
3-
put traefik/http/routers/route_api/entryPoints/0 "enter_api"
3+
put traefik/http/routers/route_api/entryPoints/0 "auth_api"
44
put traefik/http/routers/route_api/middlewares/0 "auth_api"
55
put traefik/http/routers/route_api/rule "Host(`localhost`) && PathPrefix(`/api`)"
66
put traefik/http/routers/route_api/service "api@internal"

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)