diff --git a/haproxy_manager.py b/haproxy_manager.py index 39eaffb..8d1fcd9 100644 --- a/haproxy_manager.py +++ b/haproxy_manager.py @@ -9,7 +9,7 @@ import psutil app = Flask(__name__) -DB_FILE = 'haproxy_config.db' +DB_FILE = '/etc/haproxy/haproxy_config.db' TEMPLATE_DIR = Path('templates') HAPROXY_CONFIG_PATH = '/etc/haproxy/haproxy.cfg' SSL_CERTS_DIR = '/etc/haproxy/certs' @@ -123,7 +123,7 @@ def health_check(): 'error': str(e) }), 500 -@app.route('/regenerate', methods=['GET']) +@app.route('/api/regenerate', methods=['GET']) def regenerate_conf(): try: generate_config() @@ -336,6 +336,9 @@ def generate_config(): # Add ACLS config_parts.append('\n' .join(config_acls)) + # Add LetsEncrypt Backend + letsencrypt_backend = template_env.get_template('hap_letsencrypt_backend.tpl').render() + config_parts.append(letsencrypt_backend) # Add Backends config_parts.append('\n' .join(config_backends)) # Write complete configuration to tmp diff --git a/templates/hap_letsencrypt.tpl b/templates/hap_letsencrypt.tpl index 98a9968..a73379e 100644 --- a/templates/hap_letsencrypt.tpl +++ b/templates/hap_letsencrypt.tpl @@ -1,9 +1,3 @@ #Let's Encrypt SSL acl letsencrypt-acl path_beg /.well-known/acme-challenge/ use_backend letsencrypt-backend if letsencrypt-acl - - - #Pass SSL Requests to Lets Encrypt - backend letsencrypt-backend - server letsencrypt 127.0.0.1:8688 - diff --git a/templates/hap_letsencypt_backend.tpl b/templates/hap_letsencypt_backend.tpl new file mode 100644 index 0000000..8868023 --- /dev/null +++ b/templates/hap_letsencypt_backend.tpl @@ -0,0 +1,4 @@ + +#Pass SSL Requests to Lets Encrypt +backend letsencrypt-backend + server letsencrypt 127.0.0.1:8688 \ No newline at end of file