Try WSO2 Cloud for Free
Sign in
||
Skip to end of metadata
Go to start of metadata

All API calls are directed through the cloud gateways in the traditional model of API management. This approach has inherent limitations such as the following.

  • There may be inefficiencies if only the API backend or only the API consumers are not in the cloud.
  • Security concerns associated with API calls going through external gateways.

WSO2 API Cloud offers users the hybrid gateway deployment option for deploying API Gateway(s) on-premise. This enables them to get the best of both the API Cloud and API Manager.

  • Rapid deployment model and low total cost of ownership: Most of the API management infrastructure (including management user interfaces, the developer portal, and analytics) is in the cloud, which makes it always accessible to you and your subscribers. This cloud-based infrastructure does not require maintenance.
  • High performance, security, and compliance: You can put the API gateway anywhere including your own network. This cuts down the network overhead, ensures security and compliance, and removes the need for VPN or another network connectivity solution.

The following are the options that allow you to test the On-Prem gateway with WSO2 API Cloud.

Option 1 - Run the On-Prem gateway using the downloaded binary file

Follow the steps below to configure and test an On-Prem gateway.

Step 1 - Download your On-Prem Gateway

  1. Log in to WSO2 API Cloud (https://api.cloud.wso2.com) as an Admin User

  2. In the API Publisher, click On-Prem Gateways.

  3. Click Download On-Prem Gateway to start the download.
  4. You will receive a confirmation of the download as shown below after the download starts.


Step 2 - Configure your On-Prem Gateway

  1. Configure the Gateway by going to <ON-PREM_GATEWAY_HOME>/bin, and executing the configuration script:
    On Windows: configure-gateway.bat --run
    On Linux/Mac OS: sh configure-gateway.sh
    Your Gateway will be configured with the required settings to integrate with the API Cloud.
  2. Provide your email address, organization key, and password.
    Your organization key will be displayed as shown below.
  3. The status of the On-Prem Gateway will be displayed after completion.



Step 3 - Run the on-premise gateway

  1. Start the API Gateway by going to <ON-PREM_GATEWAY_HOME>/bin, and executing the startup script:
    On Windows: wso2server.bat --run
    On Linux/Mac OS: sh wso2server.sh
  2. The status of the On-Prem Gateway will be updated after you start the gateway


Step 4 - Test your on-premise gateway 

  1. Log in to WSO2 API Cloud and create an API.
  2. Subscribe to and invoke the API.
  3. Invoke the API using cURL.

The cURL command to invoke the GET method of the API should be similar to the following:

curl -k -X GET --header 'Accept: text/xml' --header 'Authorization: Bearer dXNlckBvcmcuY29tQHRlc3RPcmcxMjM6UGFzc3dvcmQ=’
'https://gateway.api.cloud.wso2.com:443/t/ccc2222/phoneverify/1.0.0/CheckPhoneNumber?PhoneNumber=18006785432&LicenseKey=0'

Replace https://gateway.api.cloud.wso2.com:443 in the above cURL command with your on-premise gateway URL as indicated below, and run it. The response to this cURL should be identical to that received in the previous step.

curl -k -X GET --header 'Accept: text/xml' --header 'Authorization: Bearer dXNlckBvcmcuY29tQHRlc3RPcmcxMjM6UGFzc3dvcmQ=’
'https://on-premise-gateway-ip:8243/t/ccc2222/phoneverify/1.0.0/CheckPhoneNumber?PhoneNumber=18006785432&LicenseKey=0'

Note that you can also use the HTTP port for API invocations. The HTTP port number would be 8280 by default. An example is given below.

curl -X GET --header 'Accept: text/xml' --header 'Authorization: Bearer dXNlckBvcmcuY29tQHRlc3RPcmcxMjM6UGFzc3dvcmQ=’
'http://on-premise-gateway-ip:8280/t/ccc2222/phoneverify/1.0.0/CheckPhoneNumber?PhoneNumber=18006785432&LicenseKey=0'

When you run multiple On-Premise gateways on the same server or virtual machine (VM), you must change the default port of each Gateway with an offset value to avoid port conflicts. An offset defines the number by which all ports in the runtime (e.g., HTTP/S ports) will be increased. For example, if the default HTTPS port is 8243 and the offset is 1, the effective HTTPS port will change to 8244. For each additional On-Premise Gateway instance that you run in the same server or virtual machine, you have to set the port offset to a unique value. The offset of the default port is considered to be 0.

There are two ways to set an offset to a port:

  • Pass the port offset to the server during startup. The following command starts the server with the default port incremented by 1.
./wso2server.sh -DportOffset=1
  • Set the port offset in the Ports section in the <ON-PREM_GATEWAY_HOME>/repository/conf/carbon.xml file as shown below.
<Offset>1</Offset>
  1. If your request is successful, your response will be similar to the following.

    <?xml version="1.0" encoding="utf-8"?>
    <PhoneReturn xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ws.cdyne.com/PhoneVerify/query">
      <Company>Toll Free</Company>
      <Valid>true</Valid>
      <Use>Assigned to a code holder for normal use.</Use>
      <State>TF</State>
      <RC />
      <OCN />
      <OriginalNumber>18006785432</OriginalNumber>
      <CleanNumber>8006785432</CleanNumber>
      <SwitchName />
      <SwitchType />
      <Country>United States</Country>
      <CLLI />
      <PrefixType>Landline</PrefixType>
      <LATA />
      <sms>Landline</sms>
      <Email />
      <AssignDate>Unknown</AssignDate>
      <TelecomCity />
      <TelecomCounty />
      <TelecomState>TF</TelecomState>
      <TelecomZip />
      <TimeZone />
      <Lat />
      <Long />
      <Wireless>false</Wireless>
      <LRN />
    </PhoneReturn>
    

Option 2 - Run the On-Prem gateway as a docker container

Before you begin...

Install Docker. For instructions, go here.

  1. Log in to docker.cloud.wso2.com with your username and password.

    docker login docker.cloud.wso2.com
    Username: your_username@wso2.com
    Password: ******
    Login Succeeded
  2. Pull the docker image. A sample command is given below.

    docker pull docker.cloud.wso2.com/onprem-gateway:2.1.0
  3. Run the docker container.

    docker run -p127.0.0.1:8243:8243 -p127.0.0.1:8280:8280 -e "WSO2_CLOUD_ORG_KEY=your_organization_key" -e "WSO2_CLOUD_EMAIL=your_username@wso2.com" -e "WSO2_CLOUD_PASSWORD=your_cloud_password" docker.cloud.wso2.com/onprem-gateway:2.1.0
  4. Test your On-Prem gateway.
  • If you create/update an API and publish/re-publish it from API Cloud Publisher, it could take up to a maximum of 10 minutes before your changes become effective in the on-premise gateway.
  • If you create/update a throttling tier from API Cloud, it could take up to a maximum of 15 minutes before your changes become effective in the on-premise gateway.
  • Statistics of API usage in your on-premise gateway are published to API Cloud every 6 - 6.5 hours.

Overriding the default gateway configurations

  1. Go to <API-M_HOME>/repository/conf/

  2. Replace the default configurations in the on-premise-gateway.properties file with the required custom configurations.

    • To customize the synchronization time interval of the API updates:
      Replace the api.update.task.cron expression with a custom cron expression.

    • To customize the synchronization time interval of the Throttling tiers:
      Replace the throttling.synchronization.cron expression with a custom cron expression.

    • To customize the time period it takes for API statistics to get published to API cloud:
      Replace the file.data.upload.task.cron expression with a custom cron expression.

Related links

  • No labels