1
0
Fork 0
This commit is contained in:
Joao M 2022-08-17 22:04:10 +00:00
parent ad8aef16a2
commit fee0126442
6 changed files with 9 additions and 10 deletions

View file

@ -197,7 +197,6 @@ easymapping:
host2.com.br: host2.com.br:
containers: containers:
- other:3000 - other:3000
ssl: false
redirect: redirect:
www.host1.com.br: http://host1.com.br www.host1.com.br: http://host1.com.br
@ -207,7 +206,7 @@ easymapping:
containers: containers:
- container:80 - container:80
redirect-ssl: false redirect-ssl: false
ssl: true ssl: true
- port: 8080 - port: 8080
hosts: hosts:

View file

@ -165,7 +165,7 @@ class HaproxyConfigGenerator:
easymapping["443"]["hosts"][hostname] = dict(easymapping[port]["hosts"][hostname]) easymapping["443"]["hosts"][hostname] = dict(easymapping[port]["hosts"][hostname])
easymapping["443"]["hosts"][hostname]["letsencrypt"] = False easymapping["443"]["hosts"][hostname]["letsencrypt"] = False
easymapping["443"]["hosts"][hostname]["redirect_ssl"] = False easymapping["443"]["hosts"][hostname]["redirect_ssl"] = False
easymapping["443"]["ssl_cert"] = self.ssl_cert_letsecncrypt easymapping["443"]["ssl"] = True
self.letsencrypt_hosts.append(hostname) if hostname not in self.letsencrypt_hosts else self.letsencrypt_hosts self.letsencrypt_hosts.append(hostname) if hostname not in self.letsencrypt_hosts else self.letsencrypt_hosts
@ -175,12 +175,12 @@ class HaproxyConfigGenerator:
filename = "{}/{}.pem".format( filename = "{}/{}.pem".format(
self.ssl_cert_haproxy, d[host_label] self.ssl_cert_haproxy, d[host_label]
) )
easymapping[port]["ssl_cert"] = filename easymapping[port]["ssl"] = True
with open(filename, 'wb') as file: with open(filename, 'wb') as file:
file.write( file.write(
base64.b64decode(d[ssl_label]) base64.b64decode(d[ssl_label])
) )
if self.label.get_bool(self.label.create([definition, "ssl"])): if self.label.get_bool(self.label.create([definition, "ssl"])):
easymapping[port]["ssl_cert"] = self.ssl_cert_haproxy easymapping[port]["ssl"] = True
return easymapping.values() return easymapping.values()

View file

@ -12,7 +12,7 @@ easymapping:
www.host1.local: https://host1.local www.host1.local: https://host1.local
- port: 443 - port: 443
ssl_cert: /certs/haproxy/host1.local.pem ssl: true
hosts: hosts:
host1.local: host1.local:
containers: containers:

View file

@ -1,4 +1,4 @@
{% if "ssl_cert" in o %} {% if "ssl" in o %}
bind *:{{ o["port"] }} ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1 bind *:{{ o["port"] }} ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
{% elif "h2" in o and o["h2"] %} {% elif "h2" in o and o["h2"] %}
bind *:{{ o["port"] }} proto h2 bind *:{{ o["port"] }} proto h2

View file

@ -19,7 +19,7 @@ easymapping:
www.host1.com.br: http://host1.com.br www.host1.com.br: http://host1.com.br
- port: 443 - port: 443
ssl_cert: /certs/haproxy/mycert.pem ssl: True
hosts: hosts:
host1.com.br: host1.com.br:
containers: containers:

View file

@ -168,7 +168,7 @@ def test_parser_finds_services_raw():
"byjg.ca":"https://www.somehost.com.br", "byjg.ca":"https://www.somehost.com.br",
"www.byjg.ca":"https://www.somehost.com.br" "www.byjg.ca":"https://www.somehost.com.br"
}, },
"ssl_cert":CERT_FILE "ssl": True
}, },
{ {
"mode":"http", "mode":"http",
@ -247,7 +247,7 @@ def test_parser_static_raw():
}, },
{ {
"port": 443, "port": 443,
"ssl_cert": "/certs/haproxy/mycert.pem", "ssl": True,
"hosts": { "hosts": {
"host1.com.br": { "host1.com.br": {
"containers": [ "containers": [