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")
|
print(f"Service host \"{serviceHost}\" is not a valid URL")
|
||||||
return
|
return
|
||||||
|
|
||||||
print(f"Adding \"{domain}\" -> \"{serviceHost}\"")
|
print(f"Adding \"{domain}{path}\" -> \"{serviceHost}\"")
|
||||||
|
|
||||||
traefikConfig.addSubPathRouter(subPathName, domain, path, serviceHost)
|
traefikConfig.addSubPathRouter(subPathName, domain, path, serviceHost)
|
||||||
traefikConfig.save()
|
traefikConfig.save()
|
||||||
|
@ -39,7 +39,18 @@ class TraefikConfig:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def addSubPathRouter(self, name, domain, path, serviceHost):
|
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
|
# Add router
|
||||||
self.configYml["http"]["routers"][name] = {
|
self.configYml["http"]["routers"][name] = {
|
||||||
@ -50,10 +61,6 @@ class TraefikConfig:
|
|||||||
"service": name
|
"service": name
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add trailing slash
|
|
||||||
if not serviceHost.endswith("/"):
|
|
||||||
serviceHost += "/"
|
|
||||||
|
|
||||||
# Add service
|
# Add service
|
||||||
self.configYml["http"]["services"][name] = {
|
self.configYml["http"]["services"][name] = {
|
||||||
"loadBalancer": {
|
"loadBalancer": {
|
||||||
@ -77,16 +84,6 @@ class TraefikConfig:
|
|||||||
|
|
||||||
def hasPathRewrite(self, name):
|
def hasPathRewrite(self, name):
|
||||||
return name in self.configYml["http"]["middlewares"]
|
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):
|
def hasService(self, name):
|
||||||
return name in self.configYml["http"]["services"]
|
return name in self.configYml["http"]["services"]
|
||||||
|
Loading…
Reference in New Issue
Block a user