Loading…
Loading…
Learn how to configure HAProxy to capture SOAP request bodies and forward them to SOAP-to-REST for service discovery and mapping.
This documentation describes how to configure HAProxy to capture SOAP request bodies and forward them to the SOAP-to-REST platform. This capability enables the SOAP-to-REST platform to discover and map services without requiring the installation of agents directly on backend servers (source: deploy/lb-connectors/haproxy/README.md).
The core mechanism involves a Lua script that runs at the HAProxy proxy tier. This script captures the SOAP request body and then performs an envelope POST to the SOAP-to-REST generic ingest endpoint (/ingest/v1/generic/traffic). This feature is currently in a ship-and-maintain status for v1 (source: deploy/lb-connectors/haproxy/README.md).
The HAProxy SOAP Body Capture mechanism leverages HAProxy's Lua scripting capabilities to intercept and process HTTP traffic. When a SOAP request passes through a configured HAProxy frontend, the associated Lua script (s2r_body_capture.lua) is invoked. This script is designed to:
/ingest/v1/generic/traffic endpoint of the SOAP-to-REST platform. This forwarding is a "fire-and-forget" operation, meaning it does not block the original client request to the backend server (source: deploy/lb-connectors/haproxy/README.md).This process allows the SOAP-to-REST platform to passively observe and learn about the SOAP services being proxied by HAProxy, facilitating service discovery and mapping without direct integration with the backend application servers.
Before configuring HAProxy for SOAP body capture, ensure the following requirements are met:
| Requirement | Version | Description |
|---|---|---|
| HAProxy | 2.5+ | Required for the core.httpclient API. For HAProxy versions 1.6-2.4, the core.httpclient API is not available; a compatibility shim using core.tcp() is required. Contact support for assistance with older versions (source: deploy/lb-connectors/haproxy/README.md). |
| Lua | 5.3+ | Bundled with HAProxy 2.5+ (source: deploy/lb-connectors/haproxy/README.md). |
| Network | N/A | The HAProxy host must have network connectivity to reach the SOAP-to-REST relay VM or Cloud Run ingest URL on port 8080 (for HTTP) or 443 (for TLS) (source: deploy/lb-connectors/haproxy/README.md). |
Follow these steps to deploy and configure HAProxy for SOAP body capture.
Copy the s2r_body_capture.lua script to the HAProxy Lua directory and set appropriate permissions.
sudo cp s2r_body_capture.lua /etc/haproxy/lua/s2r_body_capture.lua
sudo chown root:root /etc/haproxy/lua/s2r_body_capture.lua
sudo chmod 644 /etc/haproxy/lua/s2r_body_capture.lua
(source: deploy/lb-connectors/haproxy/README.md)
Create or edit the HAProxy environment file (e.g., /etc/haproxy/env or your systemd EnvironmentFile) to define the SOAP-to-REST ingest endpoint and the HAProxy host IP.
S2R_ENDPOINT=http://<your-relay-host>:8080/ingest/v1/generic/traffic
GATEWAY_IP=<your-haproxy-host-ip>
Replace the following placeholders:
<your-relay-host>: The IP address or hostname of the SOAP-to-REST relay VM or Cloud Run internal URL.<your-haproxy-host-ip>: The IP address of the HAProxy host as it is seen by backend servers.
(source: deploy/lb-connectors/haproxy/README.md)Modify your haproxy.cfg file to load the Lua script and apply the capture directives.
Add the following line to the global section to load the Lua script:
global
lua-load /etc/haproxy/lua/s2r_body_capture.lua
Add the following directives to each frontend that proxies SOAP traffic. Alternatively, you can add them to the defaults section to apply them globally.
frontend soap-frontend
bind *:443 ssl crt /etc/haproxy/certs/server.pem
default_backend soap-backend
# S2R body capture — remove or comment out to disable
http-request lua.s2r_capture_request
http-response lua.s2r_capture_response
To restrict the capture to specific SOAP paths and reduce overhead, you can use conditions with the http-request and http-response directives:
http-request lua.s2r_capture_request if { path_beg /services/ /soap/ }
http-response lua.s2r_capture_response if { path_beg /services/ /soap/ }
(source: deploy/lb-connectors/haproxy/README.md)
After making changes to haproxy.cfg and environment variables, validate the configuration and reload HAProxy.
# Syntax check
haproxy -c -f /etc/haproxy/haproxy.cfg
# Reload without dropping connections
sudo systemctl reload haproxy
# or: sudo haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -sf $(cat /run/haproxy.pid)
(source: deploy/lb-connectors/haproxy/README.md)
After reloading HAProxy, send a test SOAP request through the configured frontend and verify that the SOAP-to-REST platform received the captured body.
Check the ingest endpoint health:
curl -s http://<your-relay-host>:8080/ingest/v1/health
Query the SOAP-to-REST database (API publisher action):
SELECT COUNT(*), MAX(created_at)
FROM s2r_generic_request_log
WHERE gateway_type = 'haproxy';
Check the SOAP-to-REST Admin UI:
Navigate to Observability > Live Traffic Log and filter by Gateway: haproxy.
(source: deploy/lb-connectors/haproxy/README.md)
The following environment variables are used to configure the HAProxy SOAP body capture script:
| Name | Type | Default | Description