mirror of
https://github.com/FAUSheppy/athq-vm-management
synced 2025-12-06 22:01:35 +01:00
feat: add ssl termination switch
This commit is contained in:
11
vm.py
11
vm.py
@@ -16,7 +16,7 @@ listen {name}
|
|||||||
HA_PROXY_TEMPLATE_SNI = '''
|
HA_PROXY_TEMPLATE_SNI = '''
|
||||||
frontend {subdomain}.{basedomain}
|
frontend {subdomain}.{basedomain}
|
||||||
bind 0.0.0.0:80
|
bind 0.0.0.0:80
|
||||||
bind 0.0.0.0:443 ssl
|
bind 0.0.0.0:443 {ssl}
|
||||||
http-request redirect scheme https unless {{ ssl_fc }}
|
http-request redirect scheme https unless {{ ssl_fc }}
|
||||||
default_backend {name}
|
default_backend {name}
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@ class VM:
|
|||||||
self.hostname = args.get("hostname")
|
self.hostname = args.get("hostname")
|
||||||
self.subdomains = args.get("subdomains")
|
self.subdomains = args.get("subdomains")
|
||||||
self.ports = args.get("ports")
|
self.ports = args.get("ports")
|
||||||
|
self.terminateSSL = args.get("terminate-ssl")
|
||||||
self.network = args.get("network") or "default"
|
self.network = args.get("network") or "default"
|
||||||
self.lease = self._get_lease_for_hostname()
|
self.lease = self._get_lease_for_hostname()
|
||||||
self.ip = self.lease.get("ipaddr")
|
self.ip = self.lease.get("ipaddr")
|
||||||
@@ -65,8 +66,14 @@ class VM:
|
|||||||
# https components #
|
# https components #
|
||||||
for subdomain in self.subdomains:
|
for subdomain in self.subdomains:
|
||||||
compositeName = "-".join((self.hostname, subdomain.replace(".","-")))
|
compositeName = "-".join((self.hostname, subdomain.replace(".","-")))
|
||||||
|
|
||||||
|
# check ssl termination #
|
||||||
|
ssl = ""
|
||||||
|
if self.terminateSSL:
|
||||||
|
ssl = "ssl"
|
||||||
|
|
||||||
component = HA_PROXY_TEMPLATE_SNI.format(name=compositeName, basedomain=BASE_DOMAIN,
|
component = HA_PROXY_TEMPLATE_SNI.format(name=compositeName, basedomain=BASE_DOMAIN,
|
||||||
ip=self.ip, subdomain=subdomain)
|
ip=self.ip, subdomain=subdomain, ssl=ssl)
|
||||||
components.append(component)
|
components.append(component)
|
||||||
|
|
||||||
return components
|
return components
|
||||||
|
|||||||
Reference in New Issue
Block a user