|
@@ -4,6 +4,7 @@ import argparse
|
4
|
4
|
import etcdlib
|
5
|
5
|
import jinja2
|
6
|
6
|
import os
|
|
7
|
+import os.path
|
7
|
8
|
|
8
|
9
|
parser = argparse.ArgumentParser()
|
9
|
10
|
parser.add_argument('--name', help='Name of the docker host to request certificates for', default='unknown')
|
|
@@ -26,16 +27,18 @@ while True:
|
26
|
27
|
defaults = fetcher.get_label('com.chameth.proxy.default')
|
27
|
28
|
for container, values in fetcher.get_label('com.chameth.proxy').items():
|
28
|
29
|
networks = fetcher.get_networks(container)
|
29
|
|
- services.append({
|
30
|
|
- 'protocol': protocols[container] if container in protocols else 'http',
|
31
|
|
- 'vhosts': domains[container],
|
32
|
|
- 'host': next(iter(networks.values())), # TODO: Pick a bridge sensibly?
|
33
|
|
- 'port': values,
|
34
|
|
- 'certificate': args.cert_path % domains[container][0],
|
35
|
|
- 'trusted_certificate': args.trusted_cert_path % domains[container][0],
|
36
|
|
- 'certificate_key': args.cert_key_path % domains[container][0],
|
37
|
|
- 'default': container in defaults,
|
38
|
|
- })
|
|
30
|
+ certfile = args.cert_path % domains[container][0];
|
|
31
|
+ if os.path.isfile(certfile):
|
|
32
|
+ services.append({
|
|
33
|
+ 'protocol': protocols[container] if container in protocols else 'http',
|
|
34
|
+ 'vhosts': domains[container],
|
|
35
|
+ 'host': next(iter(networks.values())), # TODO: Pick a bridge sensibly?
|
|
36
|
+ 'port': values,
|
|
37
|
+ 'certificate': args.cert_path % domains[container][0],
|
|
38
|
+ 'trusted_certificate': args.trusted_cert_path % domains[container][0],
|
|
39
|
+ 'certificate_key': args.cert_key_path % domains[container][0],
|
|
40
|
+ 'default': container in defaults,
|
|
41
|
+ })
|
39
|
42
|
|
40
|
43
|
with open('/nginx-config/vhosts.conf', 'w') as f:
|
41
|
44
|
print('Writing vhosts.conf...', flush=True)
|