feat: kubernetes ingress/alt http port support

This commit is contained in:
Kathrin Maurer
2025-02-28 16:15:51 +01:00
parent 73106f6d57
commit 9634f35a1e
3 changed files with 9 additions and 3 deletions

View File

@@ -26,20 +26,21 @@ def dump_config(vmList, masterAddress):
[ f.write(c) for c in vmo.dumpIptables(remove=True)] [ f.write(c) for c in vmo.dumpIptables(remove=True)]
with open("/etc/nginx/stream_include.conf", "w") as f: with open("/etc/nginx/stream_include.conf", "w") as f:
# ssl passthrough/no-terminate # # ssl passthrough/no-terminate #
ssl_passthrough_map = [] ssl_passthrough_map = []
for vmo in vmList: for vmo in vmList:
relevant_subdomains = filter(lambda x: x.get("no-terminate-ssl"), vmo.subdomains) relevant_subdomains = filter(lambda x: x.get("no-terminate-ssl"), vmo.subdomains)
for s in relevant_subdomains: for s in relevant_subdomains:
print(s) print(s, "ssl_target_port", s.get("ssl_target_port"))
# build the map contents # # build the map contents #
if s.get("include-subdomains"): if s.get("include-subdomains"):
match = "~.*{}".format(s.get("name")) match = "~.*{}".format(s.get("name"))
else: else:
match = s.get("name") match = s.get("name")
ssl_passthrough_map.append("{} {}:443;".format(match, vmo.ip)) ssl_target_port = s.get("ssl_target_port") or 443
ssl_passthrough_map.append("{} {}:{};".format(match, vmo.ip, ssl_target_port))
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates")) environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
template = environment.get_template("nginx_stream_ssl_map.conf.j2") template = environment.get_template("nginx_stream_ssl_map.conf.j2")

View File

@@ -74,7 +74,11 @@ server{
{% else %} {% else %}
location / { location / {
{{ proxy_pass_blob }} {{ proxy_pass_blob }}
{% if http_target_port %}
proxy_pass http://{{ targetip }}:{{ http_target_port }};
{% else %}
proxy_pass http://{{ targetip }}:80; proxy_pass http://{{ targetip }}:80;
{% endif %}
} }
{% endif %} {% endif %}

1
vm.py
View File

@@ -168,6 +168,7 @@ class VM:
include_subdomains=subdomain.get("include-subdomains"), include_subdomains=subdomain.get("include-subdomains"),
cert_optional=cert_optional, cert_optional=cert_optional,
cert_non_optional=cert_non_optional, cert_non_optional=cert_non_optional,
http_target_port=subdomain.get("http_target_port"),
cert_header_line=header_line) cert_header_line=header_line)
components.append(component) components.append(component)