From 3a3d52790796bdb7850fed3eade7b112dcecdbd0 Mon Sep 17 00:00:00 2001 From: bunkerity Date: Fri, 11 Dec 2020 17:03:43 +0100 Subject: [PATCH] UI - basic read fixes --- confs/global/nginx.conf | 3 +++ entrypoint/multisite-config.sh | 2 +- examples/web-ui/docker-compose.yml | 22 +++++++++++++--------- ui/entrypoint.py | 13 ++++++++++--- ui/static/css/custom.css | 2 +- ui/templates/end.html | 2 +- ui/templates/head.html | 7 ++++--- ui/templates/menu.html | 6 +++--- 8 files changed, 36 insertions(+), 21 deletions(-) diff --git a/confs/global/nginx.conf b/confs/global/nginx.conf index ff09a52..4306573 100644 --- a/confs/global/nginx.conf +++ b/confs/global/nginx.conf @@ -71,6 +71,9 @@ http { # resolvers to use resolver %DNS_RESOLVERS% ipv6=off; + # remove ports when sending redirects + port_in_redirect off; + # lua path and dicts lua_package_path "/usr/local/lib/lua/?.lua;;"; %WHITELIST_IP_CACHE% diff --git a/entrypoint/multisite-config.sh b/entrypoint/multisite-config.sh index 6ac2c6a..9e7865f 100644 --- a/entrypoint/multisite-config.sh +++ b/entrypoint/multisite-config.sh @@ -16,7 +16,7 @@ if [ "$MULTISITE" = "yes" ] ; then for server in $servers ; do SERVER_PREFIX="/etc/nginx/${server}/" if grep "/etc/letsencrypt/live" ${SERVER_PREFIX}https.conf > /dev/null && [ ! -f /etc/letsencrypt/live/${server}/fullchain.pem ] ; then - /opt/scripts/certbot-new.sh "$1" "$(cat ${SERVER_PREFIX}email-lets-encrypt.txt)" + /opt/scripts/certbot-new.sh "$server" "$(cat ${SERVER_PREFIX}email-lets-encrypt.txt)" fi if grep "modsecurity.conf" ${SERVER_PREFIX}server.conf > /dev/null ; then modsec_custom="" diff --git a/examples/web-ui/docker-compose.yml b/examples/web-ui/docker-compose.yml index cd9e407..1949e4f 100644 --- a/examples/web-ui/docker-compose.yml +++ b/examples/web-ui/docker-compose.yml @@ -13,21 +13,20 @@ services: - ./web-files:/www:ro - autoconf:/etc/nginx environment: - - SERVER_NAME=admin.domain.com # replace with your domain + - SERVER_NAME=admin.website.com # replace with your domain - MULTISITE=yes - AUTO_LETS_ENCRYPT=yes - REDIRECT_HTTP_TO_HTTPS=yes - DISABLE_DEFAULT_SERVER=yes - - USE_CLIENT_CACHE=yes - USE_GZIP=yes - USE_BROTLI=yes - - admin.domain.com_SERVE_FILES=no - - admin.domain.com_USE_AUTH_BASIC=yes - - admin.domain.com_AUTH_BASIC_USER=admin # change it to something hard to guess - - admin.domain.com_AUTH_BASIC_PASSWORD=admin # change it to something hard to guess - - admin.domain.com_USE_REVERSE_PROXY=yes - - admin.domain.com_REVERSE_PROXY_URL=/admin/ # change it to something hard to guess - - admin.domain.com_REVERSE_PROXY_HOST=http://myui:5000/ + - admin.website.com_SERVE_FILES=no + - admin.website.com_USE_AUTH_BASIC=yes + - admin.website.com_AUTH_BASIC_USER=admin # change it to something hard to guess + - admin.website.com_AUTH_BASIC_PASSWORD=admin # change it to something hard to guess + - admin.website.com_USE_REVERSE_PROXY=yes + - admin.website.com_REVERSE_PROXY_URL=/admin/ # change it to something hard to guess + - admin.website.com_REVERSE_PROXY_HOST=http://myui:5000/ labels: - "bunkerized-nginx.UI" @@ -37,3 +36,8 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - autoconf:/etc/nginx + environment: + - ABSOLUTE_URI=https://admin.website.com/admin/ # change it to your full URI + +volumes: + autoconf: diff --git a/ui/entrypoint.py b/ui/entrypoint.py index aff7d6c..b964eca 100644 --- a/ui/entrypoint.py +++ b/ui/entrypoint.py @@ -1,12 +1,19 @@ #!/usr/bin/python3 -from flask import Flask, render_template +from flask import Flask, render_template, current_app import wrappers +import os + app = Flask(__name__, static_url_path="/", static_folder="static", template_folder="templates") +ABSOLUTE_URI = "" +if "ABSOLUTE_URI" in os.environ : + ABSOLUTE_URI = os.environ["ABSOLUTE_URI"] +app.config["ABSOLUTE_URI"] = ABSOLUTE_URI @app.route('/') +@app.route('/home') def home(): check, instances = wrappers.get_instances() if not check : @@ -17,14 +24,14 @@ def home(): return render_template("home.html", title="Home", instances_number=len(instances), services_number=len(services)) @app.route('/instances') -def home(): +def instances(): check, instances = wrappers.get_instances() if not check : return render_template("error.html", title="Error", error=instances) return render_template("instances.html", title="Instances", instances=instances) @app.route('/services') -def home(): +def services(): check, services = wrappers.get_services() if not check : return render_template("error.html", title="Error", error=services) diff --git a/ui/static/css/custom.css b/ui/static/css/custom.css index 404dfb7..74d37ab 100644 --- a/ui/static/css/custom.css +++ b/ui/static/css/custom.css @@ -13,5 +13,5 @@ } main > .container { - padding: 60px 15px 0; + padding: 100px 15px 0; } diff --git a/ui/templates/end.html b/ui/templates/end.html index efbcaf1..243fdcd 100644 --- a/ui/templates/end.html +++ b/ui/templates/end.html @@ -1 +1 @@ - + diff --git a/ui/templates/head.html b/ui/templates/head.html index 44701b4..cf055fb 100644 --- a/ui/templates/head.html +++ b/ui/templates/head.html @@ -1,10 +1,11 @@ + - {{ title }} + bunkerized-nginx-ui - {{ title }} - - + + diff --git a/ui/templates/menu.html b/ui/templates/menu.html index bcbf30d..6661117 100644 --- a/ui/templates/menu.html +++ b/ui/templates/menu.html @@ -8,13 +8,13 @@