watch services for autoconf/k8s and support real IP in default http server

This commit is contained in:
bunkerity 2023-04-04 11:45:34 +02:00
parent d3d0136bf5
commit 0b71819d22
3 changed files with 20 additions and 2 deletions

View File

@ -213,6 +213,8 @@ class IngressController(Controller, ConfigCaller):
what = self.__networkingv1.list_ingress_for_all_namespaces
elif watch_type == "configmap":
what = self.__corev1.list_config_map_for_all_namespaces
elif watch_type == "service":
what = self.__corev1.list_service_for_all_namespaces
else:
raise Exception(f"Unsupported watch_type {watch_type}")
@ -283,7 +285,7 @@ class IngressController(Controller, ConfigCaller):
def process_events(self):
self._set_autoconf_load_db()
watch_types = ("pod", "ingress", "configmap")
watch_types = ("pod", "ingress", "configmap", "service")
threads = [
Thread(target=self.__watch, args=(watch_type,))
for watch_type in watch_types

View File

@ -0,0 +1,16 @@
{% if USE_REAL_IP == "yes" +%}
{% for element in read_lines("/var/cache/bunkerweb/realip/combined.list") +%}
set_real_ip_from {{ element }};
{% endfor +%}
{% if REAL_IP_FROM != "" %}
{% for element in REAL_IP_FROM.split(" ") +%}
set_real_ip_from {{ element }};
{% endfor %}
{% endif %}
real_ip_header {{ REAL_IP_HEADER }};
{% if REAL_IP_RECURSIVE == "yes" +%}
real_ip_recursive on;
{% else +%}
real_ip_recursive off;
{% endif +%}
{% endif %}

View File

@ -383,9 +383,9 @@ if __name__ == "__main__":
logger.info("Successfuly sent /data/cache folder")
# restart nginx
logger.info("Stopping temp nginx ...")
if integration == "Linux":
# Stop temp nginx
logger.info("Stopping temp nginx ...")
proc = subprocess_run(
["/usr/sbin/nginx", "-s", "stop"],
stdin=DEVNULL,