fix web ui multiple variables and add default error pages

This commit is contained in:
bunkerity 2021-06-02 15:33:42 +02:00
parent 445032406b
commit 8cda1baf77
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
22 changed files with 279 additions and 12 deletions

View File

@ -17,6 +17,7 @@ COPY confs/ /opt/confs
COPY scripts/ /opt/scripts
COPY lua/ /usr/local/lib/lua
COPY antibot/ /antibot
COPY defaults/ /defaults
COPY settings.json /opt
COPY misc/cron /etc/crontabs/nginx

View File

@ -17,6 +17,7 @@ COPY confs/ /opt/confs
COPY scripts/ /opt/scripts
COPY lua/ /usr/local/lib/lua
COPY antibot/ /antibot
COPY defaults/ /defaults
COPY settings.json /opt
COPY misc/cron /etc/crontabs/nginx

View File

@ -24,6 +24,7 @@ COPY confs/ /opt/confs
COPY scripts/ /opt/scripts
COPY lua/ /usr/local/lib/lua
COPY antibot/ /antibot
COPY defaults/ /defaults
COPY settings.json /opt
COPY misc/cron /etc/crontabs/nginx

View File

@ -24,6 +24,7 @@ COPY confs/ /opt/confs
COPY scripts/ /opt/scripts
COPY lua/ /usr/local/lib/lua
COPY antibot/ /antibot
COPY defaults/ /defaults
COPY settings.json /opt
COPY misc/cron /etc/crontabs/nginx

View File

@ -17,6 +17,7 @@ COPY confs/ /opt/confs
COPY scripts/ /opt/scripts
COPY lua/ /usr/local/lib/lua
COPY antibot/ /antibot
COPY defaults/ /defaults
COPY settings.json /opt
COPY misc/cron /etc/crontabs/nginx

View File

@ -11,3 +11,16 @@ location = {{ page }} {
}
{% endfor %}
{% endif %}
{% set default_errors = ["400", "401", "403", "404", "429", "500", "501", "502", "503", "504"] %}
{% for default_error in default_errors %}
{% if not default_error + "=" in ERRORS %}
error_page {{ default_error }} /errors/{{ default_error }}.html;
location = /errors/{{ default_error }}.html {
root /defaults;
modsecurity off;
internal;
}
{% endif %}
{% endfor %}

View File

@ -56,7 +56,7 @@ server {
# serve local files
{% if SERVE_FILES == "yes" %}
include {{ NGINX_PREFIX}}serve-files.conf;
include {{ NGINX_PREFIX }}serve-files.conf;
{% endif %}
# allowed HTTP methods

23
defaults/errors/400.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>400 - Bad Request</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>400 - Bad Request</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/401.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>401 - Unauthorized</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>401 - Unauthorized</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/403.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>403 - Forbidden</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>403 - Forbidden</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/404.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>404 - Not Found</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>404 - Not Found</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/429.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>429 - Too Many Requests</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>429 - Too Many Requests</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/500.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>500 - Internal Server Error</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>500 - Internal Server Error</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/501.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>501 - Not Implemented</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>501 - Not Implemented</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/502.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>502 - Bad Gateway</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>502 - Bad Gateway</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/503.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>503 - Service Unavailable</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>503 - Service Unavailable</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

23
defaults/errors/504.html Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>504 - Gateway Time-out</title>
<style>
body {
background-color: #1d70b7;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
</head>
<body>
<div class="centered" style="color: white;">
<h1>504 - Gateway Time-out</h1>
&#128737;&#65039; this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> &#128737;&#65039;
</div>
</body>
</html>

View File

@ -5,6 +5,8 @@ services:
mywww:
image: bunkerity/bunkerized-nginx
restart: always
depends_on:
- myui
ports:
- 80:8080
- 443:8443
@ -36,7 +38,6 @@ services:
image: bunkerity/bunkerized-nginx-ui
restart: always
depends_on:
- mywww
- myuiproxy
volumes:
- autoconf:/etc/nginx

View File

@ -968,7 +968,7 @@
},
{
"context": "multisite",
"default": "",
"default": "no",
"env": "REVERSE_PROXY_WS",
"id": "reverse-proxy-ws",
"label": "Reverse proxy ws",

View File

@ -39,6 +39,7 @@ class Config :
self.__dict_to_env(env_file, conf)
proc = subprocess.run(["/bin/su", "-c", "/opt/gen/main.py --settings /opt/settings.json --templates /opt/confs --output /etc/nginx --variables " + env_file, "nginx"], capture_output=True)
stderr = proc.stderr.decode("ascii")
#stdout = proc.stdout.decode("ascii")
if stderr != "" or proc.returncode != 0 :
raise Exception("Error from generator (return code = " + str(proc.returncode) + ") : " + stderr)
@ -60,12 +61,17 @@ class Config :
check = False
for category in self.__settings :
for param in self.__settings[category]["params"] :
multiple = False
if param["type"] != "multiple" :
real_params = [param]
else :
real_params = param["params"]
multiple = True
for real_param in real_params :
if k == real_param["env"] and real_param["context"] == "multisite" and re.search(real_param["regex"], v) :
if (((not multiple and k == real_param["env"]) or
(multiple and re.search("^" + real_param["env"] + "_" + "[0-9]+$", k))) and
real_param["context"] == "multisite" and
re.search(real_param["regex"], v)) :
check = True
if not check :
raise Exception("Variable " + k + " is not valid.")

View File

@ -23,15 +23,25 @@
{% for k, v in config["CONFIG"].get_settings().items() %}
<div class="tab-pane fade {{ check.class }}" id="edit-{{ v["id"] }}-{{ id_server_name }}" role="tabpanel" aria-labelledby="edit-{{ v["id"] }}-{{ id_server_name }}-tab">
{% for param in v["params"] %}
<div class="row mb-3" id="form-edit-{{ id_server_name }}-{{ param["id"] }}">
{% if param["type"] != "multiple" and param["context"] == "multisite" %}
<div class="row mb-3" id="form-edit-{{ id_server_name }}-{{ param["id"] }}">
{{ form_service_gen("form-edit-" + id_server_name + "-" + param["id"], param["label"], param["type"], service[param["env"]], param["env"])|safe }}
{% elif param["context"] == "multisite" %}
</div>
{% elif param["type"] == "multiple" %}
{% set gen = {"value": False} %}
{% for param2 in param["params"] %}
{% if param2["context"] == "multisite" %}
{% set x = gen.update({"value": True}) %}
{% endif %}
{% endfor %}
{% if gen["value"] %}
<div class="row mb-3" id="form-edit-{{ id_server_name }}-{{ param["id"] }}">
{{ form_service_gen_multiple("form-edit-" + id_server_name + "-" + param["id"], param["label"], param["params"])|safe }}
{% if template_data.update({"javascript": template_data.javascript + form_service_gen_multiple_values("form-edit-" + id_server_name + "-" + param["id"], param["params"], service)}) %}
{% if template_data.update({"javascript": template_data.javascript + form_service_gen_multiple_values("form-edit-" + id_server_name + "-" + param["id"], param["params"], service)}) %}
{% endif %}
</div>
{% endif %}
{% endif %}
</div>
{% endfor %}
</div>
{% if check.update({"class": ""}) %}

View File

@ -22,25 +22,27 @@
{% for k, v in config["CONFIG"].get_settings().items() %}
<div class="tab-pane fade {{ check.class }}" id="new-{{ v["id"] }}" role="tabpanel" aria-labelledby="new-{{ v["id"] }}-tab">
{% for param in v["params"] %}
<div class="row mb-3" id="form-new-{{ param["id"] }}">
{% if param["type"] != "multiple" and param["context"] == "multisite" %}
<div class="row mb-3" id="form-new-{{ param["id"] }}">
{% set default = {"value": param["default"]} %}
{% if param["env"] in config["CONFIG"].get_config() %}
{% set x = default.update({"value": config["CONFIG"].get_config()[param["env"]]}) %}
{% endif %}
{{ form_service_gen("form-new-" + param["id"], param["label"], param["type"], default["value"], param["env"])|safe }}
</div>
{% elif param["type"] == "multiple" %}
{% set gen = {"value": False} %}
{% for param in param["params"] %}
{% if param["context"] == "multisite" %}
{% for param2 in param["params"] %}
{% if param2["context"] == "multisite" %}
{% set x = gen.update({"value": True}) %}
{% endif %}
{% endfor %}
{% if gen["value"] %}
<div class="row mb-3" id="form-new-{{ param["id"] }}">
{{ form_service_gen_multiple("form-new-" + param["id"], param["label"], param["params"])|safe }}
</div>
{% endif %}
{% endif %}
</div>
{% endfor %}
</div>
{% if check.update({"class": ""}) %}