diff --git a/Dockerfile b/Dockerfile index 5e0bf2b..d6c69d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Dockerfile-amd64 b/Dockerfile-amd64 index 99e5617..67f0691 100644 --- a/Dockerfile-amd64 +++ b/Dockerfile-amd64 @@ -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 diff --git a/Dockerfile-arm32v7 b/Dockerfile-arm32v7 index 8907bf3..44a3cae 100644 --- a/Dockerfile-arm32v7 +++ b/Dockerfile-arm32v7 @@ -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 diff --git a/Dockerfile-arm64v8 b/Dockerfile-arm64v8 index bfa2d2f..50cc64a 100644 --- a/Dockerfile-arm64v8 +++ b/Dockerfile-arm64v8 @@ -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 diff --git a/Dockerfile-i386 b/Dockerfile-i386 index 942dc5c..7000610 100644 --- a/Dockerfile-i386 +++ b/Dockerfile-i386 @@ -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 diff --git a/confs/site/error.conf b/confs/site/error.conf index 1636d1a..4856ff2 100644 --- a/confs/site/error.conf +++ b/confs/site/error.conf @@ -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 %} diff --git a/confs/site/server.conf b/confs/site/server.conf index c532358..b352121 100644 --- a/confs/site/server.conf +++ b/confs/site/server.conf @@ -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 diff --git a/defaults/errors/400.html b/defaults/errors/400.html new file mode 100644 index 0000000..4f499df --- /dev/null +++ b/defaults/errors/400.html @@ -0,0 +1,23 @@ + + + 400 - Bad Request + + + +
+

400 - Bad Request

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/401.html b/defaults/errors/401.html new file mode 100644 index 0000000..d257e3c --- /dev/null +++ b/defaults/errors/401.html @@ -0,0 +1,23 @@ + + + 401 - Unauthorized + + + +
+

401 - Unauthorized

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/403.html b/defaults/errors/403.html new file mode 100644 index 0000000..8e2dd12 --- /dev/null +++ b/defaults/errors/403.html @@ -0,0 +1,23 @@ + + + 403 - Forbidden + + + +
+

403 - Forbidden

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/404.html b/defaults/errors/404.html new file mode 100644 index 0000000..55fe339 --- /dev/null +++ b/defaults/errors/404.html @@ -0,0 +1,23 @@ + + + 404 - Not Found + + + +
+

404 - Not Found

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/429.html b/defaults/errors/429.html new file mode 100644 index 0000000..c353431 --- /dev/null +++ b/defaults/errors/429.html @@ -0,0 +1,23 @@ + + + 429 - Too Many Requests + + + +
+

429 - Too Many Requests

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/500.html b/defaults/errors/500.html new file mode 100644 index 0000000..c679dc7 --- /dev/null +++ b/defaults/errors/500.html @@ -0,0 +1,23 @@ + + + 500 - Internal Server Error + + + +
+

500 - Internal Server Error

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/501.html b/defaults/errors/501.html new file mode 100644 index 0000000..82baeda --- /dev/null +++ b/defaults/errors/501.html @@ -0,0 +1,23 @@ + + + 501 - Not Implemented + + + +
+

501 - Not Implemented

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/502.html b/defaults/errors/502.html new file mode 100644 index 0000000..b098a4c --- /dev/null +++ b/defaults/errors/502.html @@ -0,0 +1,23 @@ + + + 502 - Bad Gateway + + + +
+

502 - Bad Gateway

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/503.html b/defaults/errors/503.html new file mode 100644 index 0000000..a3414e3 --- /dev/null +++ b/defaults/errors/503.html @@ -0,0 +1,23 @@ + + + 503 - Service Unavailable + + + +
+

503 - Service Unavailable

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/defaults/errors/504.html b/defaults/errors/504.html new file mode 100644 index 0000000..e084812 --- /dev/null +++ b/defaults/errors/504.html @@ -0,0 +1,23 @@ + + + 504 - Gateway Time-out + + + +
+

504 - Gateway Time-out

+ 🛡️ this website is protected with bunkerized-nginx 🛡️ +
+ + diff --git a/examples/web-ui/docker-compose.yml b/examples/web-ui/docker-compose.yml index 17e60eb..d541f33 100644 --- a/examples/web-ui/docker-compose.yml +++ b/examples/web-ui/docker-compose.yml @@ -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 diff --git a/settings.json b/settings.json index 827b4ab..52c7f25 100644 --- a/settings.json +++ b/settings.json @@ -968,7 +968,7 @@ }, { "context": "multisite", - "default": "", + "default": "no", "env": "REVERSE_PROXY_WS", "id": "reverse-proxy-ws", "label": "Reverse proxy ws", diff --git a/ui/Config.py b/ui/Config.py index 53ad683..7d8ad88 100644 --- a/ui/Config.py +++ b/ui/Config.py @@ -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.") diff --git a/ui/templates/services-edit.html b/ui/templates/services-edit.html index f2352bf..bef7aaa 100644 --- a/ui/templates/services-edit.html +++ b/ui/templates/services-edit.html @@ -23,15 +23,25 @@ {% for k, v in config["CONFIG"].get_settings().items() %}
{% for param in v["params"] %} -
{% if param["type"] != "multiple" and param["context"] == "multisite" %} +
{{ form_service_gen("form-edit-" + id_server_name + "-" + param["id"], param["label"], param["type"], service[param["env"]], param["env"])|safe }} - {% elif param["context"] == "multisite" %} +
+ {% 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"] %} +
{{ 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 %} +
{% endif %} {% endif %} -
{% endfor %}
{% if check.update({"class": ""}) %} diff --git a/ui/templates/services-new.html b/ui/templates/services-new.html index 69aa035..c5285d7 100644 --- a/ui/templates/services-new.html +++ b/ui/templates/services-new.html @@ -22,25 +22,27 @@ {% for k, v in config["CONFIG"].get_settings().items() %}
{% for param in v["params"] %} -
{% if param["type"] != "multiple" and param["context"] == "multisite" %} +
{% 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 }} +
{% 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"] %} +
{{ form_service_gen_multiple("form-new-" + param["id"], param["label"], param["params"])|safe }} +
{% endif %} {% endif %} -
{% endfor %}
{% if check.update({"class": ""}) %}