fixes
All checks were successful
Publish Docker Image / docker (push) Successful in 1m21s

This commit is contained in:
Lee 2024-08-28 03:01:48 +01:00
parent 7d861aad76
commit 019261a988
2 changed files with 13 additions and 16 deletions

@ -33,7 +33,7 @@ class AddSubPathCommand(Command):
print(f"Service host \"{serviceHost}\" is not a valid URL")
return
print(f"Adding \"{domain}\" -> \"{serviceHost}\"")
print(f"Adding \"{domain}{path}\" -> \"{serviceHost}\"")
traefikConfig.addSubPathRouter(subPathName, domain, path, serviceHost)
traefikConfig.save()

@ -39,7 +39,18 @@ class TraefikConfig:
}
def addSubPathRouter(self, name, domain, path, serviceHost):
self.addPathRewrite(name, path)
# Add trailing slashs
if not path.endswith("/"):
path += "/"
if not serviceHost.endswith("/"):
serviceHost += "/"
# Add path stripper middleware
self.configYml["http"]["middlewares"][name] = {
"stripPrefix": {
"prefixes": [path]
}
}
# Add router
self.configYml["http"]["routers"][name] = {
@ -50,10 +61,6 @@ class TraefikConfig:
"service": name
}
# Add trailing slash
if not serviceHost.endswith("/"):
serviceHost += "/"
# Add service
self.configYml["http"]["services"][name] = {
"loadBalancer": {
@ -77,16 +84,6 @@ class TraefikConfig:
def hasPathRewrite(self, name):
return name in self.configYml["http"]["middlewares"]
def addPathRewrite(self, name, path):
if not path.endswith("/"): # Add trailing slash
path += "/"
self.configYml["http"]["middlewares"][name] = {
"stripPrefix": {
"prefixes": [path]
}
}
def hasService(self, name):
return name in self.configYml["http"]["services"]