This example demonstrates how to configure Membrane as an outgoing API gateway. It acts as a controlled egress point for internal services that need to call external APIs. The architecture provides:
Internal services send API requests to Membrane on a fixed port (e.g., 2000
). Membrane validates and
filters the request before forwarding it to the configured target API.
Unlike reverse proxies, Membrane is configured to:
X-Forwarded-For
header to avoid leaking internal IPsconf/proxies.xml
to configure the gateway:<api port="2000" name="Outgoing Gateway">
<request>
<headerFilter>
<include>Accept.*</include>
<include>Content-Type</include>
<include>Content-Length</include>
<include>X-Api-Key</include>
<exclude>.*</exclude>
</headerFilter>
<!-- Client authentication via API key -->
<apiKey>
<keys>
<secret value="abc123"/ >
</keys>
<headerExtractor />
</apiKey>
</request>
<target url="https://www.predic8.de/"/>
</api>
./membrane.sh
(Linux/macOS)membrane.cmd
(Windows)Send a test request using curl:
curl -v http://localhost:2000 \
-H "X-Api-Key: abc123" \
-H "User-Agent: secret" \
-H "Authorization: secret"
Membrane will forward only the headers explicitly included in the filter. For example, User-Agent
and
Authorization
will be removed, while X-Api-Key
is forwarded.
Use the Admin Console at http://localhost:9000
to inspect requests, logs, and stats
<api port="9000">
<!-- Centralized auditing and Data protection -->
<adminConsole />
</api>
xForwardedForEnabled="false"
to prevent IP leakageheaderFilter
to enforce strict outbound header policiesDNS tunneling is a technique that abuses DNS to bypass firewall controls, enabling covert data exfiltration or backchannels.
To defend against it:
More info: DNS Tunneling (ICANNWiki)
Membrane offers advanced gateway features that can be added easily: