Follow the instructions below to deploy WSO2 API Manager (WSO2 API-M) in a distributed environment, as depicted in the following deployment diagram:
Click here for information on installing and configuring WSO2 API-M.
The following steps describe how to download, install, and configure WSO2 API Manager, with five instances.
- Download the WSO2 API Manager in each of the five servers in the cluster for distributed deployment.
Unzip the WSO2 API Manager zipped archive, and rename each of those directories respectively as Key Manager, Gateway, Publisher, Store, and Traffic Manager.
These five directories are located in a server of their own and are used for each component of WSO2 API-M. Each of these unzipped directories are referred to as <API-M_HOME>
or <PRODUCT_HOME>
in this document.
In each of the five servers, replace the default certificates (where CN=localhost
) with new certificates generated with proper CN values.
You need to do this in order to avoid getting an error with regard to the fact that the hostname in the certificate did not match.
Make sure to keep the following web apps, which are required, and remove the unnecessary web apps from the <API-M_HOME>/repository/deployment/server/webapps
directory of each node.
The following are the web apps required for each node:
Profile | Required web apps |
---|
Gateway Manager | am#sample#pizzashack#v1 (Only needed if the Pizzashack sample API is used)
api#am#admin#v0.11 (Only needed if you want to perform administrative tasks through Gateway Manager)
authenticationendpoint |
Gateway Worker | am#sample#pizzashack#v1 (Only needed if the Pizzashack sample API is used)
api#am#admin#v0.11 (Only needed if you want to perform administrative tasks through Gateway Manager) |
Traffic Manager | shindig (The Shindig web app is used for the WSO2 CEP Dashboard) |
Key Manager | authenticationendpoint
client-registration#v0.11
oauth2
throttle#data#v1 |
API Publisher | am#sample#pizzashack#v1 (Only needed if the Pizzashack sample API is used)
api#am#publisher#v0.11
authenticationendpoint |
API Store (Developer Portal) | api#am#store#v0.11
authenticationendpoint |
You can create the required databases for the API-M deployment in a separate server and point to the databases from the respective nodes. For information on configuring the databases, see Installing and Configuring the Databases.
Ensure that you have taken into account the respective security hardening factors (e.g., changing and encrypting the default passwords, configuring JVM security, etc.) before deploying WSO2 API-M. For more information, see the Production Deployment Guidelines in the Administration Guide.
Step 4 - Create and import SSL certificates
Create a SSL certificate for each of the WSO2 API-M nodes (e.g., Publisher, Store, Key Manager, Gateway, and Traffic Manager) and import them to the keyStore and the trustStore. For more information, see Creating SSL Certificates in the Administration Guide.
If you wish to view reports, statistics, and graphs related to the APIs deployed in the Store, you need to configure API-M Analytics. Follow the standard setup to configure API-M Analytics in a production setup, and follow the quick setup to configure API-M Analytics in a development setup.
If you want to configure high availability (HA) for API-M Analytics, see Minimum High Availability Deployment for WSO2 APIM Analytics.
You will now configure the inter-component relationships of the distributed setup by modifying their <API-M_HOME>/repository/conf/api-manager.xml
files. It is recommended to start the components in the following order: Key Manager, Publisher, Store, Traffic Manager, and Gateway.
Click here for information on configuring the connections among the components and starting the servers.
Open the <API-M_HOME>/repository/conf/axis2/axis2.xml
file and comment out the following.
<transportSender name="ws" class="org.wso2.carbon.websocket.transport.WebsocketTransportSender">
<parameter name="ws.outflow.dispatch.sequence" locked="false">outflowDispatchSeq</parameter>
<parameter name="ws.outflow.dispatch.fault.sequence" locked="false">outflowFaultSeq</parameter>
</transportSender>
Delete the WebSocketInboundEndpoint.xml
file from the <API-M_HOME>/repository/deployment/server/synapse-configs/default/inbound-endpoints
directory.
Make sure to keep the required Jaggery apps and remove the unnecessary Jaggery apps from the <API-M_HOME>/repository/deployment/server/jaggeryapps
directory of each node.
The following are the Jaggery apps that are required for each node:
| |
---|
Gateway Worker | None |
Key Manager | None |
Traffic Manager | None |
Publisher | publisher, admin |
Store | store |
If you are working with the WSO2 WUM update that was effective from the 13th February 2018 (2018-02-13), make the following changes.
Open the <API-M_HOME>/repository/conf/axis2/axis2.xml
file and comment out the following.
<!--transportSender name="wss" class="org.wso2.carbon.websocket.transport.WebsocketTransportSender">
<parameter name="ws.outflow.dispatch.sequence" locked="false">outflowDispatchSeq</parameter>
<parameter name="ws.outflow.dispatch.fault.sequence" locked="false">outflowFaultSeq</parameter>
<parameter name="ws.trust.store" locked="false">
<ws.trust.store.location>repository/resources/security/client-truststore.jks</ws.trust.store.location>
<ws.trust.store.Password>wso2carbon</ws.trust.store.Password>
</parameter>
</transportSender-->
Delete the SecureWebSocketInboundEndpoint.xml
file from the <API-M_HOME>/repository/deployment/server/synapse-configs/default/inbound-endpoints
directory.
This section involves setting up the Key Manager node and enabling it to work with the other components in a distributed deployment.
- Open the
<API-M_HOME>/repository/conf/api-manager.xml
file in the Key Manager node and change the <ServerURL>
element that appears under the <APIGateway>
section, so that it points to the API Manager Gateway.
You need to add these configurations so that when a user is deleted or when the role of a user is updated in the Key Manager, it will update the Gateway cache by clearing the cache entries of a particular user. Configure the API key validator in the Key Manager.
The Thrift protocol is normally enabled by default. However, if you have disabled the Thrift protocol, enable it as follows in the <API-M_HOME>/repository/conf/api-manager.xml
file.
Disable the data publisher in the Key Manager.
As the Key Manager does not need to publish to the Traffic Manager, you need to disable the data publisher as follows:
Open the <API-M_HOME>/repository/conf/api-manager.xml
file in the Key Manager, and change value of the <Enabled>
element that appears under the <DataPublisher>
element to false
.
<ThrottlingConfigurations>
...
<DataPublisher>
<Enabled>false</Enabled>
...
</DataPublisher>
...
</ThrottlingConfigurations>
Optionally, configure High Availability (HA) for the Key Manager.
Make a copy of the active instance configured above and use this copy as the second Key Manager active instance.
Configure a load balancer to front the two Key Manager nodes.
For information on configuring the load balancer, see Configuring the Proxy Server and the Load Balancer.
Start the WSO2 API-M Key Manager node(s) by typing the following command in the command prompt. For more information on starting a WSO2 server, see Starting the server.
This section involves setting up the API Publisher node and enabling it to work with the other components in the distributed deployment.
- Open the
<API-M_HOME>/repository/conf/api-manager.xml
file in the API Publisher node and make the following changes.Configure the Publisher with the Key Manager.
You need to update the following configuration ONLY when you do not wish to share the user stores with the WSO2 API-M instance.
Configure the Publisher with the Traffic Manager.
This configuration enables the publishing of throttling policies, custom templates, and block conditions to the Gateway node.
Configure the Publisher with the Gateway.
You need to add these configurations, because when creating an API, it calls the Gateway endpoint to create the actual Synapse file.
If you are using a single Gateway node, configure the Publisher with the Gateway as follows:
<APIGateway>
<Environments>
<Environment type="hybrid" api-console="true">
<Name>Production and Sandbox</Name>
<Description>This is a hybrid gateway that handles both production and sandbox token traffic.</Description>
<ServerURL>https://[API-Gateway-Host-or-IP]:9443/services/</ServerURL>
<Username>${admin.username}</Username>
<Password>${admin.password}</Password>
<GatewayEndpoint>http://[API-Gateway-Host]:8280,https://[API-Gateway-Host]:8243</GatewayEndpoint>
</Environment>
</Environments>
</APIGateway>
If you are using multiple Gateway nodes, configure the Publisher with the Gateway nodes as follows:
Configure the Store URL to appear in the Publisher UI.
For this purpose you need to set the <DisplayURL>
to true
and provide the URL of the Store.
Configure the blocked apps and API notifications to go to the Topic.
Open the <API-M_HOME>/repository/conf/jndi.properties
file and make the following changes.
connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientid/carbon?brokerlist='tcp://[Traffic-Manager-host]:5672'
topic.throttleData = throttleData
Disable the Thrift Server to optimize performance.
You need to configure this in the Publisher <API-M_HOME>/repository/conf/api-manager.xml
file.
<APIKeyValidator>
...
<EnableThriftServer>false</EnableThriftServer>
</APIKeyValidator>
Optionally, configure High Availability (HA) for the Publisher.
Make a copy of the active Publisher instance configured above and use this copy as the second active Publisher instance.
Configure a load balancer to front the two Publisher nodes.
For information on configuring the load balancer, see Configuring the Proxy Server and the Load Balancer.
Start the WSO2 API-M Publisher node(s) by typing the following command in the command prompt.
For more information on starting a WSO2 server, see Starting the server.
This section involves setting up the API Store node and enabling it to work with the other components in the distributed deployment.
Open the <API-M_HOME>/repository/conf/api-manager.xml
file in the API Store node and make the following changes.
Configure the API Store with the Key Manager.
Make the following throttling related changes that correspond to the Traffic Manager.
<ThrottlingConfigurations>
<EnableAdvanceThrottling>true</EnableAdvanceThrottling>
<DataPublisher>
<Enabled>false</Enabled>
……………………
</DataPublisher>
…………………
<BlockCondition>
<Enabled>false</Enabled>
………………………
</BlockCondition>
<JMSConnectionDetails>
<Enabled>false</Enabled>
…………………………………
</JMSConnectionDetails>
………………………………
</ThrottlingConfigurations>
Configure the Store with the Gateway.
If you are using a single Gateway node, configure the Store with the Gateway as follows:
<APIGateway>
<Environments>
<Environment type="hybrid">
...
<ServerURL>https://[API-Gateway-host-or-IP]:9443/services/</ServerURL>
<Username>${admin.username}</Username>
<Password>${admin.password}</Password>
<GatewayEndpoint>http://[API-Gateway-host]:8280,https://[API-Gateway-host]:8243</GatewayEndpoint>
</Environment>
</Environments>
...
</APIGateway>
If you are using multiple Gateway nodes, configure the Store with the Gateway nodes as follows:
Configure the Token Revoke endpoint to point to Gateway.
Disable the Thrift Server to optimize performance.
You need to configure this in the Store <API-M_HOME>/repository/conf/api-manager.xml
file.
<APIKeyValidator>
...
<EnableThriftServer>false</EnableThriftServer>
</APIKeyValidator>
Optionally, configure High Availability (HA) for the Store.
Make a copy of the active instance configured above and use this copy as the second API Store active instance.
Start the API Store node(s) by typing the following command in the command prompt. For more information on starting a WSO2 server, see Starting the server.
This section involves setting up the Traffic Manager node(s) and enabling it to work with the other components in a distributed deployment.
Delete the <API-M_HOME>/repository/conf/registry.xml
file and rename the <API-M_HOME>/repository/conf/registry_TM.xml
file as the registry.xml
file.
To disable registry indexing when setting up the Traffic Manager, see Registry indexing configurations.
- Delete the
<API-M_HOME>/repository/conf/axis2/axis2.xml
file and rename the <API-M_HOME>/repository/conf/axis2/axis2_TM.xml
file as the axis2.xml
file. As mentioned in step 1 (4), make sure to remove all the existing webapps in the <API-M_HOME>/repository/deployment/server/webapps
directory with the exception of the shindig web application.
Optionally, mount the <API-M_HOME>/repository/deployment/server
directory of all the Traffic Manager nodes to the shared file system.
You need to do this to share all the Throttling policies between traffic management nodes.
Disable the Thrift Server to optimize performance.
You need to configure this in the TrafficManager<API-M_HOME>/repository/conf/api-manager.xml
file.
<APIKeyValidator>
...
<EnableThriftServer>false</EnableThriftServer>
</APIKeyValidator>
Optionally, configure High Availability (HA) for the Traffic Manager.
Make a copy of the active instance configured above and use this copy as the second active Traffic Manager instance.
Start the WSO2 API-M Traffic Manager node(s) by typing the following command in the command prompt. For more information on starting a WSO2 server, see Starting the server.
This section involves setting up the Gateway node and enabling it to work with the other components in the distributed deployment.
- Open the
<API-M_HOME>/repository/conf/api-manager.xml
file in the Gateway node. Modify the api-manager.xml
file as follows. This configures the connection to the Key Manager component.
If you need to enable JSON Web Token (JWT), you have to enable it in all Gateway and Key Manager components.
For more information on configuring JWT, see Generating JSON Web Token.
Configure the Gateway to communicate with the Traffic Manager.
You need to do this to enable Throttling for the Traffic Manager node(s).
Comment out the following section to prevent warning messages during start up of the Gateway node in the cluster setup.
<JMSEventPublisherParameters>
<java.naming.factory.initial>org.wso2.andes.jndi.PropertiesFileInitialContextFactory</java.naming.factory.initial>
<java.naming.provider.url>repository/conf/jndi.properties</java.naming.provider.url>
<transport.jms.DestinationType>topic</transport.jms.DestinationType>
<transport.jms.Destination>throttleData</transport.jms.Destination>
<transport.jms.ConcurrentPublishers>allow</transport.jms.ConcurrentPublishers>
<transport.jms.ConnectionFactoryJNDIName>TopicConnectionFactory</transport.jms.ConnectionFactoryJNDIName>
</JMSEventPublisherParameters>
Start the WSO2 API-M Gateway node by typing the following command in the command prompt. For more information on starting a WSO2 server, see Starting the server.