diff --git a/docs/web_ui.md b/docs/web_ui.md index bf3cd35..c72cc40 100644 --- a/docs/web_ui.md +++ b/docs/web_ui.md @@ -96,6 +96,9 @@ services: restart: always depends_on: - my-bunkerized-ui + networks: + - services-net + - ui-net ports: - 80:8080 - 443:8443 @@ -103,16 +106,16 @@ services: - ./letsencrypt:/etc/letsencrypt - bunkerized-vol:/etc/nginx environment: - - SERVER_NAME=admin.example.com # replace with your domain + - SERVER_NAME=admin.example.com # replace with your domain - MULTISITE=yes - USE_API=yes - - API_URI=/ChangeMeToSomethingHardToGuess # change it to something hard to guess + must match API_URI from myui service + - API_URI=/ChangeMeToSomethingHardToGuess # change it to something hard to guess + must match API_URI from myui service - AUTO_LETS_ENCRYPT=yes - REDIRECT_HTTP_TO_HTTPS=yes - admin.example.com_USE_REVERSE_PROXY=yes - - admin.example.com_REVERSE_PROXY_URL=/admin-changeme/ # change it to something hard to guess + - admin.example.com_REVERSE_PROXY_URL=/admin-changeme/ # change it to something hard to guess - admin.example.com_REVERSE_PROXY_HOST=http://my-bunkerized-ui:5000 - - admin.example.com_REVERSE_PROXY_HEADERS=X-Script-Name /admin # must match REVERSE_PROXY_URL + - admin.example.com_REVERSE_PROXY_HEADERS=X-Script-Name /admin-changeme # must match REVERSE_PROXY_URL - admin.example.com_USE_MODSECURITY=no labels: - "bunkerized-nginx.UI" @@ -125,13 +128,13 @@ services: networks: - ui-net volumes: - - autoconf:/etc/nginx + - bunkerized-vol:/etc/nginx environment: - - ABSOLUTE_URI=https://admin.example.com/admin/ # change it to your full URI + - ABSOLUTE_URI=https://admin.example.com/admin-changeme/ # change it to your full URI - DOCKER_HOST=tcp://my-docker-proxy:2375 - - API_URI=/ChangeMeToSomethingHardToGuess # must match API_URI from bunkerized-nginx - - ADMIN_USERNAME=admin # change it to something hard to guess - - ADMIN_PASSWORD=changeme # change it to a good password + - API_URI=/ChangeMeToSomethingHardToGuess # must match API_URI from bunkerized-nginx + - ADMIN_USERNAME=admin # change it to something hard to guess + - ADMIN_PASSWORD=changeme # change it to a good password my-docker-proxy: image: tecnativa/docker-socket-proxy @@ -148,6 +151,7 @@ services: networks: ui-net: services-net: + name: services-net volumes: bunkerized-vol: diff --git a/lua/api.lua b/lua/api.lua index 344f3af..9166b5d 100644 --- a/lua/api.lua +++ b/lua/api.lua @@ -1,4 +1,4 @@ -local M = {} +local M = {} local api_list = {} local iputils = require "resty.iputils" @@ -7,6 +7,18 @@ api_list["^/ping$"] = function () end api_list["^/reload$"] = function () + local jobs = true + local file = io.open("/etc/nginx/global.env", "r") + for line in file:lines() do + if line == "KUBERNETES_MODE=yes" or line == "SWARM_MODE=yes" then + jobs = false + break + end + end + file:close() + if jobs then + os.execute("/opt/bunkerized-nginx/entrypoint/jobs.sh") + end return os.execute("/usr/sbin/nginx -s reload") == 0 end diff --git a/tests/Dockerfile-fedora b/tests/Dockerfile-fedora index dd3c93f..395d770 100644 --- a/tests/Dockerfile-fedora +++ b/tests/Dockerfile-fedora @@ -1,6 +1,6 @@ FROM fedora:34 -RUN dnf install -y systemd +RUN dnf install -y systemd findutils RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ @@ -12,3 +12,4 @@ rm -f /lib/systemd/system/basic.target.wants/*;\ rm -f /lib/systemd/system/anaconda.target.wants/*;\ rm -f /lib/systemd/system/*tmpfiles*;\ rm -f /lib/systemd/user/*tmpfiles*;\ +find /lib/systemd/ -type f -iname "*.service" -exec rm -f {} \; diff --git a/ui/entrypoint.py b/ui/entrypoint.py index 899c0d5..3abb6d3 100644 --- a/ui/entrypoint.py +++ b/ui/entrypoint.py @@ -31,10 +31,10 @@ app.jinja_env.globals.update(form_service_gen=utils.form_service_gen) app.jinja_env.globals.update(form_service_gen_multiple=utils.form_service_gen_multiple) app.jinja_env.globals.update(form_service_gen_multiple_values=utils.form_service_gen_multiple_values) -@app.before_request -def log_request(): - app.logger.debug("Request Headers %s", request.headers) - return None +#@app.before_request +#def log_request(): +# app.logger.debug("Request Headers %s", request.headers) +# return None # Login management login_manager = LoginManager() diff --git a/ui/src/Instances.py b/ui/src/Instances.py index d6adda2..b48a2bb 100644 --- a/ui/src/Instances.py +++ b/ui/src/Instances.py @@ -56,7 +56,12 @@ class Instances : if instance.status == "running" : status = "up" instances.append(self.__instance(id, name, type, status, instance)) - if self.__docker.swarm != None : + is_swarm = True + try : + version = self.__docker.swarm.version + except : + is_swarm = False + if is_swarm : for instance in self.__docker.services.list(filters={"label" : "bunkerized-nginx.UI"}) : id = instance.id name = instance.name