mirror of https://github.com/Aidaho12/haproxy-wi
v2.0.6
1. Install script. Thx @shnacharya for help 2. Possibility of selecting the existing certificates on the servers in "Add" sections 3. Bugs fixedpull/19/head
parent
653443cdde
commit
b11b646676
|
@ -20,7 +20,14 @@ A simple web interface(user-frendly web GUI) for managing Haproxy servers. Leave
|
|||
14. Telegram notification
|
||||
|
||||
# Install
|
||||
|
||||
The installer will ask you a few questions
|
||||
```
|
||||
$ git clone https://github.com/Aidaho12/haproxy-wi.git /var/www/haproxy-wi
|
||||
$ chmod +x install
|
||||
$ cd /var/www/haproxy-wi
|
||||
$ ./install
|
||||
```
|
||||
## Manual install
|
||||
For install just [dowload](https://github.com/Aidaho12/haproxy-wi/archive/master.zip) archive and untar somewhere:
|
||||
```
|
||||
$ cd /var/www/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import html
|
||||
import cgi
|
||||
import cgitb; cgitb.enable()
|
||||
import os
|
||||
import funct
|
||||
import sql
|
||||
|
@ -16,9 +17,12 @@ config.read(path_config)
|
|||
funct.page_for_admin(level = 2)
|
||||
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
form = cgi.FieldStorage()
|
||||
cert_path = config.get('haproxy', 'cert_path')
|
||||
|
||||
listhap = sql.get_dick_permit()
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
|
||||
if form.getvalue('mode') is not None:
|
||||
serv = form.getvalue('serv')
|
||||
port = form.getvalue('port')
|
||||
|
@ -46,7 +50,7 @@ if form.getvalue('mode') is not None:
|
|||
backend = ""
|
||||
|
||||
if form.getvalue('ssl') == "https" and form.getvalue('mode') != "tcp":
|
||||
ssl = "ssl crt " + form.getvalue('cert')
|
||||
ssl = "ssl crt " + cert_path + form.getvalue('cert')
|
||||
if form.getvalue('ssl-check') == "ssl-check":
|
||||
ssl_check = " ssl verify none"
|
||||
else:
|
||||
|
@ -152,7 +156,7 @@ print('</select>'
|
|||
'<td class="addName">IP and Port:</td>'
|
||||
'<td class="addOption">'
|
||||
'<input type="text" name="ip" id="ip" title="" size="15" placeholder="172.28.0.1" class="form-control"><b>:</b>'
|
||||
'<input type="number" name="port" required title="Port for bind listner" size="5" placeholder="8080" class="form-control">'
|
||||
'<input type="number" name="port" id="listen-port" required title="Port for bind listner" size="5" placeholder="8080" class="form-control">'
|
||||
'<div class="tooltip tooltipTop">IP for bind listner, <b>if empty will be assignet on all IPs</b>. Start typing ip, or press down.</div>'
|
||||
'</td>'
|
||||
'</tr>'
|
||||
|
@ -168,8 +172,8 @@ print('</select>'
|
|||
'<input type="checkbox" id="https-listen" name="ssl" value="https" >'
|
||||
'</span>'
|
||||
'<div id="https-hide-listen" style="display: none;">'
|
||||
'<br /><span class="tooltip tooltipTop">Enter path to pem file:</span><br />'
|
||||
'<input type="text" name="cert" placeholder="/etc/ssl/certs/some_cert.pem" class="form-control" size="39" id="path-cert-listen"><br />'
|
||||
'<br /><span class="tooltip tooltipTop">Enter name to pem file, or press down:</span><br />'
|
||||
'<input type="text" name="cert" placeholder="some_cert.pem" class="form-control" size="39" id="path-cert-listen"><br />'
|
||||
'<label for="ssl-check-listen" style="margin-top: 5px;">Disable ssl verify on servers?</label><input type="checkbox" id="ssl-check-listen" name="ssl-check" value="ssl-check" checked>'
|
||||
'</div>'
|
||||
'</td>'
|
||||
|
@ -288,8 +292,8 @@ print('</select>'
|
|||
'<input type="checkbox" id="https-frontend" name="ssl" value="https">'
|
||||
'</span>'
|
||||
'<div id="https-hide-frontend" style="display: none;">'
|
||||
'<br /><span class="tooltip tooltipTop">Enter path to pem file:</span><br />'
|
||||
'<input type="text" name="cert" placeholder="/etc/ssl/certs/some_cert.pem" class="form-control" size="39" id="path-cert-frontend">'
|
||||
'<br /><span class="tooltip tooltipTop">Enter name to pem file, or press down:</span><br />'
|
||||
'<input type="text" name="cert" placeholder="some_cert.pem" class="form-control" size="39" id="path-cert-frontend">'
|
||||
'</div>'
|
||||
'</td>'
|
||||
'</tr>'
|
||||
|
@ -336,7 +340,7 @@ print('</td>'
|
|||
'<tr>'
|
||||
'<td class="addName">Select server: </td>'
|
||||
'<td class="addOption">'
|
||||
'<select required name="serv">'
|
||||
'<select required name="serv" id="serv3">'
|
||||
'<option disabled selected>Choose server</option>')
|
||||
|
||||
for i in listhap:
|
||||
|
@ -364,8 +368,8 @@ print('</select>'
|
|||
'<input type="checkbox" id="https-backend" name="ssl" value="https">'
|
||||
'</span>'
|
||||
'<div id="https-hide-backend" style="display: none;">'
|
||||
'<br /><span class="tooltip tooltipTop">Enter path to pem file.</span><br />'
|
||||
'<input type="text" name="cert" placeholder="/etc/ssl/certs/some_cert.pem" class="form-control" size="39" id="path-cert-backend"><br />'
|
||||
'<br /><span class="tooltip tooltipTop">Enter name to pem file, or press down:</span><br />'
|
||||
'<input type="text" name="cert" placeholder="some_cert.pem" class="form-control" size="39" id="path-cert-backend"><br />'
|
||||
'<label for="ssl-check" style="margin-top: 5px;">Disable ssl verify on servers?</label><input type="checkbox" id="ssl-check" name="ssl-check" value="ssl-check" checked>'
|
||||
'</div>'
|
||||
'</td>'
|
||||
|
|
|
@ -11,7 +11,7 @@ from pytz import timezone
|
|||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
|
||||
funct.head("Show HAproxy config")
|
||||
funct.head("Get Running Config")
|
||||
funct.check_config()
|
||||
funct.check_login()
|
||||
|
||||
|
|
|
@ -148,13 +148,13 @@ def update_db_v_2_0_1():
|
|||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
if e.args[0] == 'duplicate column name: type_ip':
|
||||
print('Updating... go to version 2.0.1.1')
|
||||
print('Updating... go to version 2.0.1.1<br />')
|
||||
return False
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 2.0.1")
|
||||
print("DB was update to 2.0.1<br />")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
@ -168,13 +168,13 @@ def update_db_v_2_0_1_1():
|
|||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
if e.args[0] == 'duplicate column name: enable' or e == "1060 (42S21): Duplicate column name 'enable' ":
|
||||
print('Updating... go to version 2.0.5')
|
||||
print('Updating... go to version 2.0.5<br />')
|
||||
return False
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 2.0.1.1")
|
||||
print("DB was update to 2.0.1.1<br />")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
@ -194,7 +194,7 @@ def update_db_v_2_0_5():
|
|||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 2.0.5")
|
||||
print("DB was update to 2.0.5<br />")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
|
|
@ -45,9 +45,13 @@ def logging(serv, action):
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
login = cookie.get('login')
|
||||
mess = now_utc.strftime(dateFormat) + " from " + IP + " user: " + login.value + " " + action + " for: " + serv + "\n"
|
||||
log = open(log_path + "/config_edit-"+get_data('logs')+".log", "a")
|
||||
log.write(mess)
|
||||
log.close
|
||||
try:
|
||||
log = open(log_path + "/config_edit-"+get_data('logs')+".log", "a")
|
||||
log.write(mess)
|
||||
log.close
|
||||
except IOError:
|
||||
print('<center><div class="alert alert-danger">Can\'t read write log. Please chech log_path in config</div></center>')
|
||||
pass
|
||||
|
||||
if config.get('telegram', 'enable') == "1": telegram_send_mess(mess)
|
||||
|
||||
|
@ -125,7 +129,7 @@ def head(title):
|
|||
'<link href="/inc/vertical_scrol/custom_scrollbar.css" rel="stylesheet">'
|
||||
'<link href="/inc/style.css" rel="stylesheet">'
|
||||
'<link href="/inc/nprogress.css" rel="stylesheet">'
|
||||
'<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">'
|
||||
'<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">'
|
||||
'<script src="https://code.jquery.com/jquery-1.12.4.js"></script>'
|
||||
'<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>'
|
||||
'<script src="/inc/js-cookie.js"></script>'
|
||||
|
@ -194,7 +198,7 @@ def links():
|
|||
'</li>')
|
||||
print('</ul>'
|
||||
'</nav>'
|
||||
'<div class="copyright-menu">HAproxy-WI v2.0.5</div>'
|
||||
'<div class="copyright-menu">HAproxy-WI v2.0.6</div>'
|
||||
'</div>')
|
||||
|
||||
def show_login_links():
|
||||
|
|
|
@ -58,3 +58,4 @@ server_state_file = ${haproxy_dir}/haproxy.state
|
|||
haproxy_sock = /var/run/haproxy.sock
|
||||
#Temp store configs, for haproxy check
|
||||
tmp_config_path = /tmp
|
||||
cert_path = /etc/ssl/certs/
|
||||
|
|
|
@ -22,7 +22,7 @@ def login_page(error):
|
|||
|
||||
if create_db.check_db():
|
||||
if create_db.create_table():
|
||||
print('<div class="alert alert-success">DB was created')
|
||||
print('<div class="alert alert-success">DB was created<br />')
|
||||
create_db.update_all()
|
||||
print('<br />Now you can login, default: admin/admin</div>')
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ import funct
|
|||
import ovw
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
|
||||
options = [ "acl", "http-request", "http-response", "set-uri", "set-url", "set-header", "add-header", "del-header", "replace-header", "path_beg", "url_beg()", "urlp_sub()", "tcpka", "tcplog", "forwardfor", "option" ]
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
@ -18,18 +16,15 @@ form = cgi.FieldStorage()
|
|||
req = form.getvalue('req')
|
||||
serv = form.getvalue('serv')
|
||||
act = form.getvalue('act')
|
||||
backend = form.getvalue('backend')
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
if req is not None:
|
||||
if req is 1:
|
||||
for i in options:
|
||||
if req in i:
|
||||
print(i)
|
||||
else:
|
||||
for i in options:
|
||||
print(i)
|
||||
|
||||
backend = form.getvalue('backend')
|
||||
|
||||
if form.getvalue('getcert') is not None and serv is not None:
|
||||
commands = [ "ls -1t /etc/ssl/certs/ |grep pem" ]
|
||||
funct.ssh_command(serv, commands, ip="1")
|
||||
|
||||
|
||||
|
||||
if backend is not None:
|
||||
|
||||
cmd='echo "show backend" |nc %s 1999' % serv
|
||||
|
|
|
@ -23,7 +23,6 @@ print('<h2>Admin area: View settings</h2>'
|
|||
|
||||
for section_name in config.sections():
|
||||
print('Section:', section_name)
|
||||
#print(' Options:', config.options(section_name))
|
||||
for name, value in config.items(section_name):
|
||||
print(' {} = {}'.format(name, value))
|
||||
print()
|
||||
|
|
|
@ -121,7 +121,7 @@ print('<br /><br /><table class="overview" id="group-add-table" style="display:
|
|||
'<td>IP</td>'
|
||||
'<td>Group</td>'
|
||||
'<td>Enable</td>'
|
||||
'<td>Virt</td>'
|
||||
'<td><span title="Vitrual IP, something like VRRP">Virt(?)</span></td>'
|
||||
'<td><span title="Actions with master config will automatically apply on slave">Slave for (?)</span></td>'
|
||||
'<td></td>'
|
||||
'<td></td>'
|
||||
|
|
|
@ -529,12 +529,16 @@ $( function() {
|
|||
serv: $("#serv").val()
|
||||
},
|
||||
success: function( data ) {
|
||||
response(data.split("\n"));
|
||||
data = data.replace(/\s+/g,' ');
|
||||
response(data.split(" "));
|
||||
}
|
||||
} );
|
||||
},
|
||||
autoFocus: true,
|
||||
minLength: -1
|
||||
minLength: -1,
|
||||
select: function( event, ui ) {
|
||||
$('#listen-port').focus();
|
||||
}
|
||||
});
|
||||
$( "#ip1" ).autocomplete({
|
||||
source: function( request, response ) {
|
||||
|
@ -545,10 +549,11 @@ $( function() {
|
|||
url: "options.py",
|
||||
data: {
|
||||
ip: request.term,
|
||||
serv: $("#serv").val()
|
||||
serv: $("#serv2").val()
|
||||
},
|
||||
success: function( data ) {
|
||||
response(data.split("\n"));
|
||||
data = data.replace(/\s+/g,' ');
|
||||
response(data.split(" "));
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
@ -599,4 +604,55 @@ $( function() {
|
|||
$("#optionsInput2").append(ui.item.value + " ")
|
||||
}
|
||||
});
|
||||
$( "#path-cert-listen" ).autocomplete({
|
||||
source: function( request, response ) {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
getcert:1,
|
||||
serv: $("#serv").val()
|
||||
},
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
response(data.split(" "));
|
||||
}
|
||||
} );
|
||||
},
|
||||
autoFocus: true,
|
||||
minLength: -1
|
||||
});
|
||||
$( "#path-cert-frontend" ).autocomplete({
|
||||
source: function( request, response ) {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
getcert:1,
|
||||
serv: $("#serv2").val()
|
||||
},
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
response(data.split(" "));
|
||||
}
|
||||
} );
|
||||
},
|
||||
autoFocus: true,
|
||||
minLength: -1
|
||||
});
|
||||
$( "#path-cert-backend" ).autocomplete({
|
||||
source: function( request, response ) {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
getcert:1,
|
||||
serv: $("#serv3").val()
|
||||
},
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
response(data.split(" "));
|
||||
}
|
||||
} );
|
||||
},
|
||||
autoFocus: true,
|
||||
minLength: -1
|
||||
});
|
||||
});
|
|
@ -528,6 +528,7 @@ a:focus {
|
|||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
padding-left: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.alert-danger {
|
||||
color: #a94442;
|
||||
|
|
|
@ -10,4 +10,4 @@ numpy==1.14.0
|
|||
matplotlib==2.1.2
|
||||
urllib3==1.22
|
||||
future==0.13.1
|
||||
mysqlclient==1.3.12
|
||||
mysql-connector-python==8.0.11
|
Loading…
Reference in New Issue