Hear from Salesforce leaders on how to create and deploy Agentforce agents.
Contact Us 1-800-596-4880

Getting Started with Managed Flex Gateway on CloudHub 2.0

The goal of this tutorial is to quickly get started with Anypoint Managed Flex Gateway deployed on CloudHub 2.0. The tutorial describes how to create and run Managed Flex Gateway.

Additionally, the tutorial describes how to publish an API that is secured with a basic authentication policy.

Before You Begin

Before getting started with Flex Gateway, ensure that you have:

Deploy a Managed Flex Gateway

  1. Log in to Anypoint PlatformLeaving the Site with your Anypoint username and password.

  2. Select Runtime Manager.

  3. Click Flex Gateways in the side navigation panel.

  4. Click Managed Flex Gateway.

  5. Click Add Managed Flex Gateway.

  6. Enter a Gateway name.

  7. Select a your private space as your Deployment target.

  8. Click Advanced options.

  9. Copy and save the Managed Flex Gateway public endpoint for later testing. This is the HTTP or HTTPs URL that appears in the Public endpoint UI block, for example, https://my-gateway-abc123.edf456.us-east1.anypoint.mulesoft.com/Leaving the Site.

  10. Click Save & deploy.

    The UI returns to the dashboard of your new Managed Flex Gateway.

  11. Wait until your gateway’s Status is Running.

Publish a Simple API

  1. From your Managed Gateway’s dashboard, click Add API instance.

  2. From the Add API page, select Flex Gateway as your runtime.

  3. Select your deployed Managed Flex Gateway in the Select a gateway section.

  4. Click Next.

  5. Click Create New API.

  6. Specify an API name and select HTTP API as the asset type.

  7. Click Next.

  8. Don’t configure any downstream options.

  9. Click Next.

  10. From the Upstream page:

    1. Enter the following in the Upsream URL field:

      https://jsonplaceholder.typicode.com/
  11. Click Next.

  12. Click Save & Deploy.

    The UI takes you to the API Summary page of the newly created API instance.

    All HTTP requests made to the public endpoint are now proxied to the jsonplaceholder service.

  13. To test the API instance, replace the public endpoint placeholder and run this command in a new terminal window:

    curl -s -o /dev/null -w "%{http_code}\n" --request GET '<publicEndpoint>'
    ssh

    The command executes a GET request to the API, and then prints the resulting 200 status code, indicating success.

Secure Your API Using the Basic Authentication Policy

  1. From the API Summary page, select Policies from the side navigation panel.

  2. In the Policies page, click Add inbound policy.

  3. Select the Basic Authentication - Simple policy.

  4. Click Next.

  5. For User Name, enter user.

  6. For User Password, enter password.

  7. Click Apply.

  8. To test the API Instance without authentication, replace the public endpoint placeholder and run this command in the terminal window:

    curl -s -o /dev/null -w "%{http_code}\n" --request GET '<publicEndpoint>'
    ssh

    The command prints a resulting 401 (Unauthorized) status code, because the request does not include the Authentication context.

  9. To test the API Instance with authentication, replace the public endpoint placeholder and run this command in the terminal window:

    curl -s -o /dev/null -w "%{http_code}\n" --request GET '<publicEndpoint>' -u user:password
    ssh
    The user and password parameters must match what was specified when you applied the policy via API Manager.

    The command prints the resulting 200 status code, indicating success.