This commit is contained in:
parent
7d861aad76
commit
019261a988
@ -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": {
|
||||
@ -78,16 +85,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"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user