com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Publish through Multiple API Gateways

You can configure multiple API Gateway environments that publish to a single API Store. It helps you distribute the API Gateway load to multiple nodes and also gives you some logical separation (e.g., production vs sandbox) between the APIs in the API Store. Once you publish an API through multiple Gateway environments, the APIs in the API Store will have different server hosts and ports.

The steps below explain how to configure and publish to multiple Gateways. In this guide, we set up 3 API Manager instances in the same server. In a typical production environment, the Gateways will ideally be in separate servers.

  • Instance 1: Acts as the node that provides the API Publisher, Store and the Key Manager functionality.
  • Instance 2: Acts as a production Gateway node.
  • Instance 3: Acts as a sandbox Gateway node.
  1. Copy the API Manager product pack in 3 separate folders.
    Let's add offsets to the default ports of the two Gateway instances. A port offset ensures that there are no port conflicts when more than one WSO2 products run on the same server. 
  2. Open the <APIM_HOME>/repository/conf/carbon.xml file in the second API Manager instance and add an offset of 1 to its default port. This increments its default server port, which is 9443, by 1.

    <Offset>1</Offset>
  3. Open the <APIM_HOME>/repository/conf/carbon.xml file in the third API Manager instance and add an offset of 2 to its default port. This increments its default server port, which is 9443, by 2.

    <Offset>2</Offset>

    The thrift server should be disabled in the two Gateway instances.

  4. Open the <APIM_HOME>/repository/conf/api-manager.xml files in the second and the third API Manager instances and set the <EnableThriftServer> property to false. For example:

    <EnableThriftServer>false</EnableThriftServer>

    The two Gateway instances need to communicate with the Key Manager in the first API Manager instance. 

  5. Open the <APIM_HOME>/repository/conf/api-manager.xml files in the second and the third Gateway instances and change the following:

    <AuthManager>
        <ServerURL>https://<IP of the first instance>:9443/services/</ServerURL>
        <Username>admin</Username>
        <Password>admin</Password>
        ...
    </AuthManager>
    ...
    <APIKeyValidator>
         <ServerURL>https://<IP of the first instance>:9443/services/</ServerURL>
         <Username>admin</Username>
         <Password>admin</Password>
         ....
         <RevokeAPIURL>https://<IP of the first instance>:8243/revoke</RevokeAPIURL>
    </APIKeyValidator>

    You are done configuring the two API Gateway instances. Let's point to them from the first instance.

  6. Open the <APIM_HOME>/repository/conf/api-manager.xml file in the first API Manager instance, add two API Gateway environments under the <Environments> element and delete the <environment> that comes by default. For example:

    <Environments>
       <Environment type="production">
          <Name>Production Gateway</Name>
          <Description>Production Gateway Environment</Description>
          <ServerURL>https://localhost:9444/services/</ServerURL>
          <Username>admin</Username>
          <Password>admin</Password>
          <GatewayEndpoint>http://localhost:8281,https://localhost:8244</GatewayEndpoint>
       </Environment>
       <Environment type="sandbox">
          <Name>Sandbox Gateway</Name>
          <Description>Sandbox Gateway Environment</Description>
          <ServerURL>https://localhost:9445/services/</ServerURL>
          <Username>admin</Username>
          <Password>admin</Password>
          <GatewayEndpoint>http://localhost:8282,https://localhost:8245</GatewayEndpoint>
       </Environment>
    </Environments>

    Tip: The Gateway environment names must be unique.

    Tip: The environments you add here will be visible in a drop-down list in the API Console tab of the API Store. It allows subscribers to send API requests to any selected Gateway. 

    To stop a given Gateway environment from being displayed in the API Console tab, you can set the api-console attribute to false in the <environment> element in the api-manager.xml file. For example, <Environment type="production" api-console="false">.

  7. Start all instances.
  8. Log in to the API Publisher (first instance) and choose to edit an API.
  9. Navigate to the Manage tab, expand the Gateway Environments section and note that the two Gateway environments listed there.


    In a typical production setup, you will publish the API to the sandbox Gateway first and then publish it to the production Gateway. In this case, let's publish to both.
  10. Select both Gateways and Save and Publish the API.
  11. Log in to the API Store (of the first instance) and select click the API to open it.
  12. In the API's Overview tab, note that it has two sets if URLs for the two Gateway instances:
You have published an API to the API Stores through multiple Gateway environments.
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.