Membrane API Gateway for Outbound Traffic

Motivation

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:

How It Works

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:

Setup

  1. Download Membrane: Membrane API Gateway
  2. Edit conf/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>
  1. Start Membrane:

Testing

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>

Security Considerations

DNS Tunneling Risk

DNS 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)

Extendability

Membrane offers advanced gateway features that can be added easily:

References