Contact Free trial Login

HTTP Proxy Pattern

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.


The HTTP Proxy sits between a caller application and a target web resource, propagating HTTP requests and responses.


You can use it to access remote web resources in a controlled manner. For example, use the HTTP Proxy when you don’t want to have numerous internal applications depending directly on external services. It also supports caching, which allows you to reduce the outbound traffic towards regular (and of course cacheable) web resources.

Use Cases

  • Exposing a remote web resource as one being hosted behind a corporate firewall

  • Adding or removing HTTP headers

  • Dynamically dispatching to different remote resources

  • Content caching of regularly accessed resource


Configuring the HTTP Proxy

<pattern:http-proxy name="http-proxy-sample"
                    outboundAddress="" />

<pattern:http-proxy name="http-proxy-sample">
    <http:inbound-endpoint address="http://localhost:8080/acme-data" />
    <http:outbound-endpoint address="" />

Inbound and outbound endpoints can either be specified as full URI address attributes, endpoint reference attributes, or child elements. When using the address attributes, you can define transformers for the request and response phases with attributes too (as shown hereafter); otherwise, transformers have to be configured within the endpoint elements.

<pattern:http-proxy name="transforming-http-proxy"
                    transformer-refs="canonical-to-acme add-acme-headers"
                    responseTransformer-refs="drop-acme-headers acme-to-canonical"
                    outboundAddress="" />

Like all the other configuration patterns, the HTTP Proxy supports inheritance, which enables re-use of common configuration elements. In the following example, the transformers configuration is shared between an abstract parent and a concrete implementation. More concrete implementations, with different addresses, could then be created.

<pattern:http-proxy name="abstract-parent-http-acme-proxy"
                   transformer-refs="canonical-to-acme add-acme-headers"
                   responseTransformer-refs="drop-acme-headers acme-to-canonical" />

<pattern:http-proxy name="concrete-acme-http-proxy"
                    outboundAddress="" />

Key Features

Path Extension

The HTTP Proxy automatically propagates the path extension received on the inbound endpoint to the path of the outbound endpoint.

This means that, within the context of the previous examples, if a request for http://localhost:8080/acme-data/extra/stuff.txt is sent to the proxy, it will be forwarded as

Similarly, query parameters are propagated. So, http://localhost:8080/acme-data?id=123 would then become

Dynamic Dispatch

Path extension is a convenient mechanism, but requires the sender to know about the URL structure of the remote service. Thanks to the HTTP Proxy’s support of the Mule Expression Language, it can generate outbound addresses based on any expression that can be evaluated on the in-flight message. When interacting with this proxy, the caller application will have to provide a HTTP header named "X-Acme-Feed" that will be used in order to build the actual outbound address. You can create more complex expressions to implement more complex dynamic dispatch rules.

For Example:

<pattern:http-proxy name="dynamic-http-proxy"
                    outboundAddress="[header:INBOUND:X-Acme-Feed]" />


Caching is a way to save already-processed data in order to avoid the cost of reprocessing the same request multiple times.To use caching, the HTTP Proxy must reference a caching strategy—for example, the HTTP caching strategy (EE)—that uses the HTTP caching directives to determine how to cache each response.

For example:

<ee:http-caching-strategy name="httpCachingStrategy"/>

<pattern:http-proxy name="http-proxy-caching-sample"
                    outboundAddress="" />

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub