From 093e7846ad11ede13abce366a9b040f6bd4e9dc1 Mon Sep 17 00:00:00 2001 From: uumas Date: Sat, 5 Apr 2025 04:38:57 +0300 Subject: [PATCH] service: Option to not pass host header to container service --- roles/service/defaults/main.yaml | 1 + roles/service/meta/argument_specs.yaml | 6 ++++++ roles/service/tasks/proxy.yaml | 1 + roles/service/vars/main.yaml | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/roles/service/defaults/main.yaml b/roles/service/defaults/main.yaml index 1db0334..040c3a2 100644 --- a/roles/service/defaults/main.yaml +++ b/roles/service/defaults/main.yaml @@ -1,6 +1,7 @@ --- service_domains: [] service_vhost_locations: [] +service_proxy_pass_host_header: true service_container_additional_networks: [] service_container_user: "" diff --git a/roles/service/meta/argument_specs.yaml b/roles/service/meta/argument_specs.yaml index cb6359b..124f661 100644 --- a/roles/service/meta/argument_specs.yaml +++ b/roles/service/meta/argument_specs.yaml @@ -20,8 +20,14 @@ argument_specs: - Required if service_domains is not empty. type: int required: false + service_proxy_pass_host_header: + description: Passed to vhost role as vhost_proxy_pass_header + type: bool + required: false + default: true service_vhost_locations: description: Passed to vhost role as vhost_locations + type: list required: false default: [] diff --git a/roles/service/tasks/proxy.yaml b/roles/service/tasks/proxy.yaml index e102bd3..ac75e36 100644 --- a/roles/service/tasks/proxy.yaml +++ b/roles/service/tasks/proxy.yaml @@ -33,4 +33,5 @@ vhost_domains: "{{ service_domains }}" vhost_proxy_target_netproto: unix vhost_proxy_target_socket: "/run/{{ service_name }}-socat.sock" + vhost_proxy_headers: "{{ _service_proxy_headers }}" vhost_locations: "{{ service_vhost_locations }}" diff --git a/roles/service/vars/main.yaml b/roles/service/vars/main.yaml index 9126f4d..6a88b6a 100644 --- a/roles/service/vars/main.yaml +++ b/roles/service/vars/main.yaml @@ -19,3 +19,7 @@ _service_container_secrets: > _service_container_requires: "{{ service_requires + ([_service_database_name + '.service'] if _service_setup_database else []) }}" _service_container_wants: "{{ service_wants + ([service_name + '-socat.socket'] if service_domains | length > 0 else []) }}" + +_service_replacement_host_header: + Host: "{{ service_name }}:{{ service_container_http_port }}" +_service_proxy_headers: "{{ _service_replacement_host_header if not service_proxy_pass_host_header else {} }}"