---
schema_version: "1"
id: ed836ea8f183b7a81900bd78811164b6ea56cabfa04fee2550c3dd5d9447d4c3
title: Domain Support for Mule 4 API Proxies
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/api-manager/latest/proxy-domain-support.md
canonical_url: https://docs.mulesoft.com/api-manager/latest/proxy-domain-support
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0e20e6a08f59f3310d5c652139a7c6a8ce933620180875a51247ede0af5b3873
description: MuleSoft Documentation Site
release: 2.x
latest: true
---
---
product: API Manager
version: 2.x
is-latest-version: true
---

# Domain Support for Mule 4 API Proxies

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Mule runtime engine (Mule) enables you to share common resources among Mule applications by defining
these resources within a Mule domain. Other Mule applications can then inherit this domain.

Your Mule applications, when accordingly configured, can access the
[resources](https://docs.mulesoft.com/mule-runtime/latest/shared-resources) declared in your domain.

Because every autogenerated proxy is a preconfigured Mule application, you can define multiple API
proxies under the same domain. You create a domain when you auto-deploy multiple proxies that use
the same host and port but have a different path.

## API Proxies and Domains Overview

API Manager enables you to automatically configure an API proxy to inherit an existing domain. All
API proxies use one of the following listener configurations when referencing a domain:

- For inbound HTTP endpoints: `api-proxy-listener-http`

- For inbound HTTPs endpoints: `api-proxy-listener-https`

Note that domains used by APIs are not supported by Runtime Fabric or CloudHub support domains.

**Important:** You may define several dependencies in a domain. Ensure that the versions of the
dependencies defined in the domain have the same or later version than the ones defined in the API
proxy that references the domain.

All the dependencies defined in the domain override the dependencies defined in the API proxy (older
or newer). For example, if the API proxy depends on a functionality defined in the HTTP transport,
but is referencing a domain using an older version of that transport, errors are thrown at runtime.

### Usage

API proxy listeners must inherit your domain HTTP listener configuration by using the listener
configuration defined in the target domain.

The following code illustrates the HTTP listener configuration defined in a target domain:

```xml
<http:listener-config name="api-proxy-listener-http">
  <http:listener-connection host="0.0.0.0" port="8081" protocol="HTTP"/>
</http:listener-config>
```

For HTTP listener configuration defined in the domain, the listener setup on the API proxy must be
defined as:

```xml
<http:listener config-ref="api-proxy-listener-http" path="${proxy.path}" responseStreamingMode="AUTO">
...
```

## Configure the Domain Used by an API Proxy

Configure the domain used by an API proxy by completing the following steps:

1.  Navigate to **Anypoint Platform** > **API Manager**.

2.  In **API Administration**, click **Add API** and select **Add new API**.

3.  Select **Mule Gateway** as your runtime.

4.  Select **Deploy a proxy application** for **Proxy type**.

5.  Select **Hybrid** for **Target Type**, then select the target server.

6.  Click **Next**.

7.  Select an API from the following options:

    - Click **Select API from Exchange** if you have an API shared with you through Exchange that
      you want to manage.

      1.  Click the API from the list under **Select API**. You can search for a specific API if
          needed.

      2.  Update the **Asset type**, **API version**, and **Asset version** if you are not using the
          latest version.

          For more information about versions in Exchange, see
          [Asset Versions](https://docs.mulesoft.com/exchange/asset-versions).

      3.  If you chose a **RAML/OAS** asset type, view the **Conformance Status** of the API to
          ensure the API is conformant. If the **Conformance Status** is nonconformant, after
          deployment, view the **Governance Report** to find and fix the conformance issues. For
          more information about the **Governance Report**, see
          [Governing API Instances](https://docs.mulesoft.com/api-manager/latest/govern-api-instances).

    - Click **Create new API**:

      1.  Enter a **Name** for the new API asset.

      2.  Select the **Asset type** from the following options:

          - **REST API:** Select this option if you have a RAML or OAS API definition file you want
            to include for your asset.

            Upload either a RAML or OAS file for your REST API. Versions 2.0.0 and later are the
            recommended versions for OAS or RAML specs, because these versions add native OAS
            support. If you upload an OAS API specification to an API proxy version 1.0 or earlier,
            your API specification is translated to RAML.

          - **HTTP API:** Select this option if you do not have an API definition file you want to
            include for your asset. For WebSocket APIs, select HTTP and then choose the WebSocket
            subtype when selecting the API from Exchange. WebSocket instances can use HTTP or
            AsyncAPI assets from Exchange.

          - **SOAP API:** Select this option if you have a WSDL API definition file or an external
            link to the file.

            Upload a WSDL file for your SOAP API or add the link to the file.

          - **GraphQL API:** Select this option if you have a GraphQL schema definition file you
            want to include for your asset.

            Upload the GraphQL schema definition for your GraphQL API.

      3.  Update the **Asset type**, **API version**, and **Asset version** if you are not using the
          latest version.

          For more information about versions in Exchange, see
          [Asset Versions](https://docs.mulesoft.com/exchange/asset-versions).

      4.  If you chose a **RAML/OAS** asset type, view the **Conformance Status** of the API to
          ensure the API is conformant. If the **Conformance Status** is nonconformant, after
          deployment, view the **Governance Report** to find and fix the conformance issues. For
          more information about the **Governance Report**, see
          [Governing API Instances](https://docs.mulesoft.com/api-manager/latest/govern-api-instances).

8.  Click **Next**.

9.  Configure the downstream configuration settings:

    Expand for configuration settings.

    <table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Field Name</th><th>Description</th><th>Required</th><th>Notes</th></tr></thead><tbody><tr><td><p><strong>Protocol</strong></p></td><td><p>Specifies whether to use HTTP or HTTPS for the validations.</p></td><td><p>Yes</p></td><td><p>If you select HTTPS, specify a TLS context for inbound traffic.</p></td></tr><tr><td><p><strong>Inbound TLS</strong></p></td><td><p>Specifies the TLS context to secure inbound traffic.</p></td><td><p>No</p></td><td><p>If you can’t see a context, ensure that you have the correct permissions.</p></td></tr><tr><td><p><strong>Port</strong></p></td><td><p>Specifies the number to use if the displayed port is incorrect.</p></td><td><p>Yes</p></td><td></td></tr><tr><td><p><strong>Base path</strong></p></td><td><p>Specifies the URL prefix for all API paths, relative to the host root. It must start and end with a leading slash <code>/</code>. If the final slash isn’t provided, the system adds it automatically.</p></td><td><p>Yes</p></td><td></td></tr><tr><td><p><strong>Instance label</strong></p></td><td><p>Specifies a label for the API.</p></td><td><p>No</p></td><td><p>If you have multiple managed instances of the same API, add a label to differentiate each instance from the others.</p></td></tr><tr><td><p><strong>Advanced Options</strong></p></td><td></td><td></td><td></td></tr><tr><td><p><strong>Consumer endpoint</strong></p></td><td><p>Specifies a proxy application’s address for consumers to use for sending requests.</p></td><td><p>No</p></td><td></td></tr><tr><td><p><strong>Client provider</strong></p></td><td><p>Specifies a client provider for the API.</p></td><td><p>Yes</p></td><td><p>Anypoint Platform acts as the client provider by default. To configure an external client provider, see <a href="https://docs.mulesoft.com/access-management/managing-api-clients">Client Providers</a>.</p></td></tr><tr><td><p><strong>Request timeout</strong></p></td><td><p>Specifies the duration after which a request times out.</p></td><td><p>No</p></td><td></td></tr><tr><td><p><strong>Proxy Version</strong></p></td><td><p>Specifies the version of the proxy to use for the endpoint.</p></td><td><p>No</p></td><td></td></tr><tr><td><p><strong>Service Name</strong></p></td><td><p>Name of your WSDL service.</p></td><td><p>Yes</p></td><td><p>Only avaliable for WSDL APIs.</p></td></tr><tr><td><p><strong>Service Port</strong></p></td><td><p>Port for your WSDL your service.</p></td><td><p>Yes</p></td><td><p>Only avaliable for WSDL APIs.</p></td></tr><tr><td><p><strong>Service Namespace</strong></p></td><td><p>Namespace of your WSDL service.</p></td><td><p>Yes</p></td><td><p>Only avaliable for WSDL APIs.</p></td></tr><tr><td><p><strong>Enable Console</strong></p></td><td><p>Specifies whether you can expose and test your API specification.</p></td><td><p>No</p></td><td><p>You can specify a different path in <strong>Console Path</strong>, for example, <code>/spec/*</code>. Only available if you have an attached API definition.</p></td></tr><tr><td><p><strong>Validations</strong></p></td><td><p>Specifies whether to validate inbound requests against a provided specification.</p></td><td><p>No</p></td><td><p>Only available if you have an attached API definition.</p></td></tr><tr><td><p><strong>Strict validations (optional)</strong></p></td><td><p>Specifies whether to validate inbound requests against query parameters.</p></td><td><p>No</p></td><td><p>Only available if you have an attached API definition.</p></td></tr><tr><td><p><strong>User Domain</strong></p></td><td><p>Specifies whether to use an API gateway domain.</p></td><td><p>No</p></td><td><p>If you chose <strong>Hybrid</strong> as the proxy deployment target previously in the configuration, ensure that you select this option.</p></td></tr></tbody></table>

10. Click **Next**.

11. Configure the upstream configuration settings:

    Expand for configuration settings.

    <table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Field Name</th><th>Description</th><th>Required</th><th>Notes</th></tr></thead><tbody><tr><td><p><strong>Upstream URL</strong></p></td><td><p>The URL to access for the proxy or the API.</p></td><td><p>Yes</p></td><td><p>For example, you can use the URL of your API asset in Exchange.</p></td></tr><tr><td><p><strong>Outbound TLS</strong></p></td><td><p>Specifies the TLS context to secure outbound traffic.</p></td><td><p>No</p></td><td><p>If you can’t see a context, ensure that you have the correct permissions.</p></td></tr></tbody></table>

12. Click **Next**.

13. Review your selections and edit them if necessary.

14. If you are ready to deploy, click **Save & Deploy**. Otherwise, you can select **Save**, to save
    the instance and deploy it at a later time.

15. After saving the API proxy configuration, perform one of the following steps:

    - Deploy the API proxy to the selected target (**Settings**, under **Deployment
      Configuration**).

    - Download the API proxy (**Actions**) and edit it in Anypoint Studio to customize your target
      domain before deploying it.

## Configuring a Domain for the First Time

When referencing a domain, Mule reads the domain Maven coordinates from the API proxy `pom.xml` file
and looks for an already deployed domain with the same semantic name. For example, in the case of an
API gateway domain with the version specified in the previous example, the semantic name is:
`gateway-proxy-domain-1.0.0-mule-domain`.

For a proxy to leverage the domain, ensure that the domain template is specified in the API proxy
`pom.xml` as a provided dependency.

To configure a domain for the first time:

1.  Obtain a domain artifact in one of the following ways:

    1.  Download the
        [API Gateway domain template](https://anypoint.mulesoft.com/exchange/org.mule.examples/gateway-proxy-domain/).

    2.  Develop your own custom domain, using the naming convention predefined in the autogenerated
        proxy:

        - `api-proxy-listener-http`: The listener configuration for HTTP communications

        - `api-proxy-listener-https`: The listener configuration for HTTPS communications

2.  Copy the Maven artifact to the `domains` folder of your running Mule distribution, for example,
    `gateway-proxy-domain-1.0.0-mule-application-template.jar`.

3.  Replace `mule-application-template` with `mule-domain`, resulting in the string:
    `gateway-proxy-domain-1.0.0-mule-domain.jar`.

    **Tip:** Ensure that the name of the artifact and its Maven coordinates match, for example:

    ```xml
    <groupId>com.mulesoft.anypoint</groupId>
    <artifactId>gateway-proxy-domain</artifactId>
    <version>1.0.0</version>
    <packaging>mule-domain</packaging>
    ```

    > [!WARNING] For Mule 4.2.2 or later to link to generated proxies, the domain file must be named
    > `proxy-shared-domain.jar` when copied to the `domains` folder.

4.  Customize the domain template to fit your usage scenario:

<dependency>
    <groupId>com.mulesoft.anypoint</groupId>
    <artifactId>gateway-proxy-domain</artifactId>
    <version>1.0.0</version>
    <classifier>mule-domain</classifier>
    <scope>provided</scope>
</dependency>

## Avoiding Port Conflicts

To successfully register an API, you must deploy the API proxy to a Mule instance using a unique
endpoint URL. Automatically generated proxies use the path: `http://0.0.0.0:8081`.

To avoid a conflict when running multiple proxies using the same domain, ensure that the proxy paths
are unique. Additionally, if you have multiple domains deployed on the same Mule instance, each
listener configuration must have a unique port for all domains to be successfully deployed and
available to the deployed proxies.

## API Gateway Domain Template

If you choose to download and manually configure your API proxy, use the **API Gateway domain
template**.

The
[API gateway domain template](https://anypoint.mulesoft.com/exchange/org.mule.examples/gateway-proxy-domain/)
is configured to have a shared HTTP listener configuration ("api-proxy-listener-http") listening on
the 8081 port. You can also have a shared HTTPS listener configuration ("api-proxy-listener-https").

To use either configuration, uncomment code from your API gateway domain template and configure your
TLS context, such as certificates and passwords. The following list provides the available listeners
configurations:

- `api-proxy-listener-http`: Used for HTTP communications, binds to all interfaces and uses port
  8081 by default.

- `api-proxy-listener-https`: Used for HTTPS communications, binds to all interfaces.+

  This domain includes a predefined `config.properties` file, which enables you to define settings
  dynamically without having to recompile the domain.

The following example illustrates the properties in the `config.properties` file:

```Properties
proxy.port=8081
implementation.protocol=HTTP
inbound.keystore.path=path
inbound.keystore.keyPassword=changeit
inbound.keystore.password=changeit
inbound.keystore.algorithm=
inbound.keystore.type=JKS
inbound.keystore.alias=alias
```

> [!WARNING] If you are using Mule 4.2.2 or later with the API gateway domain template 1.0.x, you
> must modify the domain Java archive (JAR) file for Mule to link with the generated proxies:
>
> - In `META-INF/maven/com.anypoint.mulesoft/gateway-proxy-domain/pom.xml`, change the value of
>   `groupId` to `com.mulesoft.anypoint`.
>
> - In `META-INF/mule-artifact/classloader-model.json`: change the value under `"groupId":` for
>   `com.mulesoft.anypoint`.
>
> - In `META-INF/mule-artifact/classloader-model.json`, change the value of `groupId` to
>   `com.mulesoft.anypoint`.

## See Also

- [Download Proxies](https://docs.mulesoft.com/api-manager/latest/download-proxy-task)

- [API Gateway Domain Template](https://anypoint.mulesoft.com/exchange/org.mule.examples/gateway-proxy-domain/)

- [Runtime Domains](https://docs.mulesoft.com/mule-runtime/4.2/shared-resources#assoc_apps_domain)
