1
0
Fork 0

Changes in the Static object

This commit is contained in:
Joao M 2022-09-02 23:00:16 +00:00
parent 3a3d5204a3
commit 85922425d4
6 changed files with 9 additions and 7 deletions

View file

@ -53,19 +53,19 @@ easymapping:
- domain:8181 - domain:8181
``` ```
Then map this file to `/etc/haproxy/easyconfig.yml` in your EasyHAProxy container as: Then map this file to `/etc/haproxy/static/config.yml` in your EasyHAProxy container as:
```bash ```bash
docker run -d \ docker run -d \
--name easy-haproxy-container \ --name easy-haproxy-container \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
-v /my/config.yml:/etc/haproxy/easyconfig.yml -v /my/static/:/etc/haproxy/static/ \
-e EASYHAPROXY_DISCOVER="static" \ -e EASYHAPROXY_DISCOVER="static" \
# + Environment Variables \ # + Environment Variables \
-p 80:80 \ -p 80:80 \
-p 443:443 \ -p 443:443 \
-p 1936:1936 \ -p 1936:1936 \
--network easyhaproxy --network easyhaproxy \
byjg/easy-haproxy byjg/easy-haproxy
``` ```

View file

@ -7,7 +7,7 @@ services:
haproxy: haproxy:
image: byjg/easy-haproxy image: byjg/easy-haproxy
volumes: volumes:
- ./config.yml:/etc/haproxy/easyconfig.yml - ./conf/:/etc/haproxy/static/
- ./host1.local.pem:/certs/haproxy/host1.local.pem - ./host1.local.pem:/certs/haproxy/host1.local.pem
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
environment: environment:

View file

@ -98,7 +98,7 @@ class Functions:
class Consts: class Consts:
easyhaproxy_config = "/etc/haproxy/easyconfig.yml" easyhaproxy_config = "/etc/haproxy/static/config.yml"
haproxy_config = "/etc/haproxy/haproxy.cfg" haproxy_config = "/etc/haproxy/haproxy.cfg"
certs_letsencrypt = "/certs/letsencrypt" certs_letsencrypt = "/certs/letsencrypt"
certs_haproxy = "/certs/haproxy" certs_haproxy = "/certs/haproxy"

View file

@ -14,7 +14,7 @@ def start():
processor_obj.save_config(Consts.haproxy_config) processor_obj.save_config(Consts.haproxy_config)
processor_obj.save_certs(Consts.certs_haproxy) processor_obj.save_certs(Consts.certs_haproxy)
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts() letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to run after save_config
Functions.log(Functions.EASYHAPROXY_LOG, Functions.TRACE, 'Object Found: %s' % (processor_obj.get_parsed_object())) Functions.log(Functions.EASYHAPROXY_LOG, Functions.TRACE, 'Object Found: %s' % (processor_obj.get_parsed_object()))
old_haproxy = None old_haproxy = None

View file

@ -34,7 +34,7 @@ class ContainerEnv:
class ProcessorInterface: class ProcessorInterface:
static_file = "/etc/haproxy/easyconfig.yml" static_file = Consts.easyhaproxy_config
def __init__(self, filename = None): def __init__(self, filename = None):
self.filename = filename self.filename = filename
@ -109,6 +109,8 @@ class Static(ProcessorInterface):
def get_hosts(self): def get_hosts(self):
hosts = [] hosts = []
for object in self.get_parsed_object(): for object in self.get_parsed_object():
if "hosts" not in object:
continue
for host in object["hosts"].keys(): for host in object["hosts"].keys():
hosts.append("%s:%s" % (host, object["port"])) hosts.append("%s:%s" % (host, object["port"]))
return hosts return hosts