From 17a4c96c6622762e8611e06122fc162e246c57d6 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 9 Sep 2025 02:18:07 +0900 Subject: [PATCH] Add capability to parse forward headers In case standalone watcher-api runs behind forwarders (like load balancers), it should parse specific request headers to determine the endpoint url clients actually use. Add http_proxy_to_wsgi middleware to api pipeline to handle this. Closes-Bug: #2122353 Change-Id: I27ade17f7ce1649295f92f3ea1af620df63ba1bc Signed-off-by: Takashi Kajinami --- etc/watcher/oslo-config-generator/watcher.conf | 1 + .../notes/http_proxy_to_wsgi-81ab98b39038fb39.yaml | 8 ++++++++ watcher/api/app.py | 3 +++ 3 files changed, 12 insertions(+) create mode 100644 releasenotes/notes/http_proxy_to_wsgi-81ab98b39038fb39.yaml diff --git a/etc/watcher/oslo-config-generator/watcher.conf b/etc/watcher/oslo-config-generator/watcher.conf index 6e51dea85..5474c575a 100644 --- a/etc/watcher/oslo-config-generator/watcher.conf +++ b/etc/watcher/oslo-config-generator/watcher.conf @@ -9,6 +9,7 @@ namespace = oslo.concurrency namespace = oslo.db namespace = oslo.log namespace = oslo.messaging +namespace = oslo.middleware.http_proxy_to_wsgi namespace = oslo.policy namespace = oslo.reports namespace = oslo.service.periodic_task diff --git a/releasenotes/notes/http_proxy_to_wsgi-81ab98b39038fb39.yaml b/releasenotes/notes/http_proxy_to_wsgi-81ab98b39038fb39.yaml new file mode 100644 index 000000000..6b1708cd8 --- /dev/null +++ b/releasenotes/notes/http_proxy_to_wsgi-81ab98b39038fb39.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + The ``http_proxy_to_wsgi`` middleware has been added to the api pipeline. + Now setting the ``[oslo_middleware] enable_proxy_headers_parsing`` option + to true enables parsing the HTTP headers set by forwarders, to detect + endpoint urls clients actually use. + diff --git a/watcher/api/app.py b/watcher/api/app.py index 9d67066fe..bc5c65758 100644 --- a/watcher/api/app.py +++ b/watcher/api/app.py @@ -17,6 +17,7 @@ # under the License. +from oslo_middleware import http_proxy_to_wsgi from oslo_middleware import request_id import pecan @@ -56,6 +57,8 @@ def _wrap_app(app): app = request_id.RequestId(app) + app = http_proxy_to_wsgi.HTTPProxyToWSGI(app) + return app