diff --git a/app/add.py b/app/add.py
index aef49ea9..b037eeb6 100644
--- a/app/add.py
+++ b/app/add.py
@@ -43,19 +43,19 @@ white_lists = funct.get_files(dir=white_dir, format="lst")
black_lists = funct.get_files(dir=black_dir, format="lst")
-template = template.render(title = "Add: ",
- role = role,
- user = user,
- selects = servers,
- add = form.getvalue('add'),
- conf_add = form.getvalue('conf'),
- group = user_group,
- versions = funct.versions(),
- options = sql.select_options(),
- saved_servers = sql.select_saved_servers(),
- white_lists = white_lists,
- black_lists = black_lists,
- token = token)
+template = template.render(title="Add: ",
+ role=role,
+ user=user,
+ selects=servers,
+ add=form.getvalue('add'),
+ conf_add=form.getvalue('conf'),
+ group=user_group,
+ versions=funct.versions(),
+ options=sql.select_options(),
+ saved_servers=sql.select_saved_servers(),
+ white_lists=white_lists,
+ black_lists=black_lists,
+ token=token)
print(template)
if form.getvalue('mode') is not None:
@@ -71,25 +71,29 @@ if form.getvalue('mode') is not None:
options_split = ""
ssl = ""
ssl_check = ""
+ backend = ""
- if form.getvalue('balance') is not None:
- balance = " balance " + form.getvalue('balance') + "\n"
-
+ if form.getvalue('balance') is not None:
+ balance = " balance " + form.getvalue('balance') + "\n"
+
+ if form.getvalue('health_check') is not None:
+ balance += " " + form.getvalue('health_check') + "\n"
+
if form.getvalue('ip') is not None:
ip = form.getvalue('ip')
-
- if form.getvalue('listner') is not None:
- name = "listen " + form.getvalue('listner')
- backend = ""
- end_name = form.getvalue('listner')
+
+ if form.getvalue('listener') is not None:
+ name = "listen " + form.getvalue('listener')
+ end_name = form.getvalue('listener')
elif form.getvalue('frontend') is not None:
name = "frontend " + form.getvalue('frontend')
- backend = " default_backend " + form.getvalue('backends') + "\n"
end_name = form.getvalue('frontend')
elif form.getvalue('new_backend') is not None:
name = "backend " + form.getvalue('new_backend')
- backend = ""
end_name = form.getvalue('new_backend')
+
+ if form.getvalue('backends') is not None:
+ backend = " default_backend " + form.getvalue('backends') + "\n"
if form.getvalue('maxconn'):
maxconn = " maxconn " + form.getvalue('maxconn') + "\n"
@@ -102,7 +106,7 @@ if form.getvalue('mode') is not None:
ssl_check = " ssl verify"
if not ip and port is not None:
- bind = " bind *:"+ port + " " + ssl + "\n"
+ bind = " bind *:" + port + " " + ssl + "\n"
elif port is not None:
bind = " bind " + ip + ":" + port + " " + ssl + "\n"
@@ -166,12 +170,36 @@ if form.getvalue('mode') is not None:
if form.getvalue('servers') is not None:
servers = form.getlist('servers')
server_port = form.getlist('server_port')
+ send_proxy = form.getlist('send_proxy')
+ backup = form.getlist('backup')
i = 0
for server in servers:
if form.getvalue('template') is None:
- servers_split += " server "+server+" " + server +":"+server_port[i]+ check + "\n"
+ try:
+ if send_proxy[i] == '1':
+ send_proxy_param = 'send-proxy'
+ else:
+ send_proxy_param = ''
+ except:
+ send_proxy_param = ''
+ try:
+ if backup[i] == '1':
+ backup_param = 'backup'
+ else:
+ backup_param = ''
+ except:
+ backup_param = ''
+ servers_split += " server {0} {0}:{1}{2} {3} {4} \n".format(server,
+ server_port[i],
+ check,
+ send_proxy_param,
+ backup_param)
else:
- servers_split += " server-template "+form.getvalue('prefix')+" "+form.getvalue('template-number')+" "+ server +":"+server_port[i]+ check + "\n"
+ servers_split += " server-template {0} {1} {2}:{3} {4} \n".format(form.getvalue('prefix'),
+ form.getvalue('template-number'),
+ server,
+ server_port[i],
+ check)
i += 1
compression = form.getvalue("compression")
@@ -193,16 +221,16 @@ if form.getvalue('mode') is not None:
waf = " filter spoe engine modsecurity config "+haproxy_dir+"/waf.conf\n"
waf += " http-request deny if { var(txn.modsec.code) -m int gt 0 }\n"
- config_add = "\n" + name + "\n" + bind + mode + maxconn + balance + options_split + cache_s + filter + compression_s + waf + backend + servers_split + "\n" + cache_set + "\n"
+ config_add = "\n" + name + "\n" + bind + mode + maxconn + balance + options_split + cache_s + filter + compression_s + waf + backend + servers_split + "\n" + cache_set + "\n"
if form.getvalue('new_userlist') is not None:
- name = "userlist "+form.getvalue('new_userlist')+ "\n"
+ name = "userlist "+form.getvalue('new_userlist') + "\n"
new_userlist_groups = ""
if form.getvalue('userlist-group') is not None:
groups = form.getlist('userlist-group')
for group in groups:
- new_userlist_groups += " group "+group+ "\n"
+ new_userlist_groups += " group " + group + "\n"
new_users_list = ""
if form.getvalue('userlist-user') is not None:
@@ -216,7 +244,7 @@ if form.getvalue('new_userlist') is not None:
group = ' groups '+userlist_user_group[i]
except:
group = ''
- new_users_list += " user "+user+" insecure-password " + passwords[i] +group+ "\n"
+ new_users_list += " user "+user+" insecure-password " + passwords[i] + group + "\n"
i += 1
config_add = "\n" + name + new_userlist_groups + new_users_list
@@ -239,7 +267,7 @@ try:
MASTERS = sql.is_master(serv)
for master in MASTERS:
- if master[0] != None:
+ if master[0] is not None:
funct.upload_and_restart(master[0], cfg)
stderr = funct.upload_and_restart(serv, cfg, just_save="save")
@@ -247,7 +275,7 @@ try:
print('
%s
X
' % stderr)
else:
print('' % (name, config_add, serv))
-
+
print('')
except:
pass
diff --git a/app/create_db.py b/app/create_db.py
index d35312f6..165d94a6 100644
--- a/app/create_db.py
+++ b/app/create_db.py
@@ -13,7 +13,8 @@ if mysql_enable == '1':
else:
db = "haproxy-wi.db"
import sqlite3 as sqltool
-
+
+
def check_db():
if mysql_enable == '0':
import os
@@ -46,7 +47,8 @@ def check_db():
else:
return False
con.close()
-
+
+
def get_cur():
try:
if mysql_enable == '0':
@@ -57,10 +59,11 @@ def get_cur():
database=mysql_db)
cur = con.cursor()
except sqltool.Error as e:
- funct.logging('DB ', ' '+e, haproxywi=1, login=1)
+ funct.logging('DB ', ' '+str(e), haproxywi=1, login=1)
else:
return con, cur
-
+
+
def create_table(**kwargs):
con, cur = get_cur()
if mysql_enable == '0':
@@ -76,9 +79,10 @@ def create_table(**kwargs):
activeuser INTEGER NOT NULL DEFAULT 1,
PRIMARY KEY(`id`)
);
- INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1'),
- ('editor','editor@localhost','5aee9dbd2a188839105073571bee1b1f','editor','1'),
- ('guest','guest@localhost','084e0343a0486ff05530df6c705c8bb4','guest','1');
+ INSERT INTO user (username, email, password, role, groups) VALUES
+ ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1'),
+ ('editor','editor@localhost','5aee9dbd2a188839105073571bee1b1f','editor','1'),
+ ('guest','guest@localhost','084e0343a0486ff05530df6c705c8bb4','guest','1');
CREATE TABLE IF NOT EXISTS `servers` (
`id` INTEGER NOT NULL,
`hostname` VARCHAR ( 64 ),
@@ -102,8 +106,8 @@ def create_table(**kwargs):
PRIMARY KEY(`id`)
);
INSERT INTO `role` (name, description) VALUES ('admin','Can do everything'),
- ('editor','Can edit configs'),
- ('guest','Read only access');
+ ('editor','Can edit configs'),
+ ('guest','Read only access');
CREATE TABLE IF NOT EXISTS `groups` (
`id` INTEGER NOT NULL,
@@ -624,12 +628,14 @@ def update_db_v_4_4_2_1(**kwargs):
print('Updating... go to version 4.4.2')
else:
print("An error occurred:", e)
+ cur.close()
+ con.close()
return False
else:
print("DB was update to 4.4.2")
+ cur.close()
+ con.close()
return True
- cur.close()
- con.close()
def update_db_v_4_3_2_1(**kwargs):
@@ -724,7 +730,7 @@ def update_db_v_4_5_1(**kwargs):
def update_ver(**kwargs):
con, cur = get_cur()
- sql = """update version set version = '4.5.1.0'; """
+ sql = """update version set version = '4.5.2.0'; """
try:
cur.execute(sql)
con.commit()
diff --git a/app/templates/add.html b/app/templates/add.html
index aa39f8a6..169b92b5 100644
--- a/app/templates/add.html
+++ b/app/templates/add.html
@@ -1,14 +1,17 @@
{% extends "base.html" %}
{% block content %}
{% from 'include/input_macros.html' import input, checkbox, select %}
-
+{% set balance_params = dict() %}
+{% set balance_params = {'roundrobin':'roundrobin','source':'source','leastconn':'leastconn','first':'first',
+'rdp-cookie':'rdp-cookie', 'uri':'uri', 'uri whole':'uri whole', 'static-rr': 'static-rr',
+'url_param userid':'url_param userid'} %}
+{% set checks = dict() %}
+{% set checks = {'':'Choose custom health check','option tcp-check':'Check a TCP Port',
+'option ssl-hello-chk':'Check an SSL Port','option httpchk':'Check an HTTP service',
+'option ldap-check':'Check an LDAP service', 'option mysql-check':'Check a MySql Service',
+'option pgsql-check':'Check a PgSQL Service', 'option redis-check': 'Check a Redis Service',
+'option smtpchk':'Check an SMTP service'} %}
+
@@ -26,9 +29,9 @@ h3 {
{% include 'include/add_proxy.html' %}
-
@@ -239,129 +244,125 @@ h3 {
A "frontend" section describes a set of listening sockets accepting client connections.
- All proxy names must be formed from upper and lower case letters, digits,
- '-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
+ All proxy names must be formed from upper and lower case letters, digits, '-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
case-sensitive, which means that "www" and "WWW" are two different proxies.
- Historically, all proxy names could overlap, it just caused troubles in the
- logs. Since the introduction of content switching, it is mandatory that two
- proxies with overlapping capabilities (frontend/backend) have different names.
- However, it is still permitted that a frontend and a backend share the same
+ Historically, all proxy names could overlap, it just caused troubles in the logs. Since the introduction of content switching, it is mandatory that two
+ proxies with overlapping capabilities (frontend/backend) have different names. However, it is still permitted that a frontend and a backend share the same
name, as this configuration seems to be commonly encountered.
-
-
Name:
-
-
-
-
-
-
IP and Port:
-
- :
-
-
- IP for bind listener, if empty will be assigned on all IPs.
- Start typing IP, or press down. If you are using VRRP, leave the IP field blank. If you assign an IP, the slave server will not start
-
- Enter name to pem file, or press down:
- {{ input('path-cert-frontend', name="cert", placeholder="some_cert.pem", size='39') }}
-
-
-
-
-
Maxconn:
-
- {{ input('maxconn', value='2000', type="number", title="Fix the maximum number of concurrent connections on a frontend", size='5', required='required') }}
-
This value should not exceed the global maxconn. Default global maxconn value: 2000
- Start typing options:
- {{ input('options1') }}
-
- or press down. Read more about options
-
-
- Start typing saved options:
- {{ input('saved-options1') }}
- It are the options that you saved in the "Options" tab
+
+
Name:
+
+
+
+
+
+
IP and Port:
+
+ :
+
+
+ IP for bind listener, if empty will be assigned on all IPs.
+ Start typing IP, or press down. If you are using VRRP, leave the IP field blank. If you assign an IP, the slave server will not start
+ Enter name to pem file, or press down:
+ {{ input('path-cert-frontend', name="cert", placeholder="some_cert.pem", size='39') }}
+
+
+
+
+
Maxconn:
+
+ {{ input('maxconn', value='2000', type="number", title="Fix the maximum number of concurrent connections on a frontend", size='5', required='required') }}
+
This value should not exceed the global maxconn. Default global maxconn value: 2000
+ Start typing options:
+ {{ input('options1') }}
+
+ or press down. Read more about options
+
+
+ Start typing saved options:
+ {{ input('saved-options1') }}
+ It are the options that you saved in the "Options" tab
+
Note: If you want to use a default backend, you must create a new backend first.
+
+
+
+
Advanced:
+
Show Advanced settings
+
+
+
+
+
+
+
@@ -384,144 +385,146 @@ h3 {
A "backend" section describes a set of servers to which the proxy will connect to forward incoming connections.
- All proxy names must be formed from upper and lower case letters, digits,
- '-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
+ All proxy names must be formed from upper and lower case letters, digits, '-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
case-sensitive, which means that "www" and "WWW" are two different proxies.
- Historically, all proxy names could overlap, it just caused troubles in the
- logs. Since the introduction of content switching, it is mandatory that two
- proxies with overlapping capabilities (frontend/backend) have different names.
- However, it is still permitted that a frontend and a backend share the same
+ Historically, all proxy names could overlap, it just caused troubles in the logs. Since the introduction of content switching, it is mandatory that two
+ proxies with overlapping capabilities (frontend/backend) have different names. However, it is still permitted that a frontend and a backend share the same
name, as this configuration seems to be commonly encountered.
+
+ {{ checkbox('forward_for2', title='Option Forward for if none', desc='Forward for') }}
+ {{ checkbox('redispatch2', title='Enable Redispatch', desc='Redispatch') }}
{% set values = dict() %}
- {% set values = {'None':'None','rewrite':'rewrite','indirect':'indirect','insert':'insert'} %}
- {{ select('rewrite2', values=values, first='rewrite/indirect/insert', class='force_close') }}
- {{ checkbox('prefix2', name='prefix', title='This keyword indicates that instead of relying on a dedicated cookie for the persistence, an existing one will be completed', desc='prefix', value='prefix') }}
- {{ checkbox('nocache2', name='nocache', title='This option is recommended in conjunction with the insert mode when there is a cache between the client and HAProxy', desc='nocache', value='nocache') }}
- {{ checkbox('postonly2', name='postonly', title='This option ensures that cookie insertion will only be performed on responses to POST requests', desc='postonly', value='postonly') }}
- {{ checkbox('dynamic2', name='dynamic', title='Activate dynamic cookies. When used, a session cookie is dynamically created for each server', desc='dynamic', value='dynamic') }}
-
- dynamic-cookie-key: {{ input('dynamic-cookie-key2', name='dynamic-cookie-key', placeholder="your-custom-key") }}
+ {% set values = {'Off':'Off','Server only':'Server only','Force close':'Force close','Pretend keep alive':'Pretend keep alive'} %}
+ {{ select('force_close', values=values, first='Force HTTP close', class='force_close') }}
+ {{ checkbox('cookie2', title='Set cookie', desc='Set cookie', value='1') }}
+ {{ checkbox('options-backend-show', title='Set options manually', desc='Set options') }}
+
+
+
+
+
+
+ {% set values = dict() %}
+ {% set values = {'None':'None','rewrite':'rewrite','indirect':'indirect','insert':'insert'} %}
+ {{ select('rewrite2', values=values, first='rewrite/indirect/insert', class='force_close') }}
+ {{ checkbox('prefix2', name='prefix', title='This keyword indicates that instead of relying on a dedicated cookie for the persistence, an existing one will be completed', desc='prefix', value='prefix') }}
+ {{ checkbox('nocache2', name='nocache', title='This option is recommended in conjunction with the insert mode when there is a cache between the client and HAProxy', desc='nocache', value='nocache') }}
+ {{ checkbox('postonly2', name='postonly', title='This option ensures that cookie insertion will only be performed on responses to POST requests', desc='postonly', value='postonly') }}
+ {{ checkbox('dynamic2', name='dynamic', title='Activate dynamic cookies. When used, a session cookie is dynamically created for each server', desc='dynamic', value='dynamic') }}
+
+ dynamic-cookie-key: {{ input('dynamic-cookie-key2', name='dynamic-cookie-key', placeholder="your-custom-key") }}
+
-
-
-
- Start typing options:
- {{ input('options2') }}
-
- or press down. Read more about options
-
-
- Start typing saved options:
-
- It are the options that you saved in the "Options" tab
+
+
+ Start typing options:
+ {{ input('options2') }}
+
+ or press down. Read more about options
+
+
+ Start typing saved options:
+
+ It are the options that you saved in the "Options" tab
+