Przeglądaj źródła

Allow protocols to be specified, add labels to README.

pull/4/head
Chris Smith 8 lat temu
rodzic
commit
562dc3802a
2 zmienionych plików z 15 dodań i 1 usunięć
  1. 13
    0
      README.md
  2. 2
    1
      generate.py

+ 13
- 0
README.md Wyświetl plik

12
 This container monitors `etcd` for a label specifying vhosts and proxy ports,
12
 This container monitors `etcd` for a label specifying vhosts and proxy ports,
13
 and puts them into a template file for nginx to use. 
13
 and puts them into a template file for nginx to use. 
14
 
14
 
15
+## Labels
16
+
17
+You must label any container that you wish to proxy. The following labels
18
+are understood:
19
+
20
+* `com.chameth.proxy=<port>` -- specifies the port on the container that the
21
+  proxy should connect to
22
+* `com.chameth.proxy.protocol=<protocol>` -- the protocol to use when
23
+  connecting to the container. Optional, defaults to HTTP.
24
+* `com.chameth.vhost=<host>` -- the virtual host that the proxy will accept
25
+  connections on. You can specify alternate hosts/aliases by separating them
26
+  with commas.
27
+
15
 ## Usage
28
 ## Usage
16
 
29
 
17
 TODO: Finish this!
30
 TODO: Finish this!

+ 2
- 1
generate.py Wyświetl plik

20
 while True:
20
 while True:
21
   services = []
21
   services = []
22
   domains = fetcher.get_label('com.chameth.vhost')
22
   domains = fetcher.get_label('com.chameth.vhost')
23
+  protocols = fetcher.get_label('com.chameth.proxy.protocol')
23
   for container, values in fetcher.get_label('com.chameth.proxy').items():
24
   for container, values in fetcher.get_label('com.chameth.proxy').items():
24
     networks = fetcher.get_networks(container)
25
     networks = fetcher.get_networks(container)
25
     services.append({
26
     services.append({
26
-      'protocol': 'http', # TODO: Support HTTPS
27
+      'protocol': protocols[container] if container in protocols else 'http',
27
       'vhosts': domains[container].split(','),
28
       'vhosts': domains[container].split(','),
28
       'host': next(iter(networks.values())), # TODO: Pick a bridge sensibly?
29
       'host': next(iter(networks.values())), # TODO: Pick a bridge sensibly?
29
       'port': values      
30
       'port': values      

Ładowanie…
Anuluj
Zapisz