Calling internal service endpoints in a Workflow

Your organization may have services that are not publicly accessible but contain information that would be useful to manage in Cortex. You can use an HTTP action in a Workflow and Cortex's Axon Relay to call internal services without exposing the service or authentication outside of your firewall.

How to call internal service endpoints in a Workflow

Prerequisites

Before getting started, you should have already set up the Cortex Axon agent and set your Cortex API token in the .env file.

Considerations

  • This guide describes using a Docker compose file, but note that Axon Relay can be run in Kuberenetes or other container systems.

  • As an example throughout this guide, assume a service in the network has the following endpoint:

GET http://cities.internal.my-company.com/api/cities/s => ["Seattle", "Sydney", "Shanghai" ...]

Step 1: Create request forwarding configuration

  • Create a file that defines how requests are routed.

    • The example below permits any requests, but note that the method and path can be narrowed to allow access to specific endpoints:

{
   "private": [
     {
       "method": "any", 
       "path": "/*",   
       "origin": "http://cities.internal.my-company.com"
     }
   ]
}

In your configuration, you will enter the root of your service URL as the value of origin.

Step 2: Configure Axon Docker container

  1. Create an accept file (in this example, docker-compose.yml) that defines how the container will route traffic and which routes are allowed.

    • For production employments, two replicas should be specified. The example below can be used to test the system.

services:
 relay-cities:
   image: ghcr.io/cortexapps/cortex-axon-agent:latest
   environment:
     HOSTNAME: relay-cities-${HOSTNAME:-local}
     CORTEX_API_TOKEN: $CORTEX_API_TOKEN
   volumes:
     - "./accept.cities.json:/app/accept.json"
   command: [
     "relay",
     "-a", "axon-relay-cities", # this can be any unique value
     "-f", "/app/accept.json",
   ]
  1. Start the container, which will register it with Cortex: Run the command docker compose up.

Step 3: Create the Workflow in Cortex

  1. Add an HTTP request block to your Workflow. Configure the block:

    • Block name: Enter a human readable name.

    • Slug: Enter a unique identifier for the block.

    • HTTP method: GET

    • URL: Enter a URL in the following format: http://[your-configuration-alias]@relay-proxy.cortex.io[/desired/url/path]

    • Headers: For more information on headers, see the HTTP request block documentation.

  2. After saving your changes, run the Workflow.

    • Click Run at the top of the Workflow.

    • Learn more about Workflow runs in Running a Workflow.

After running the Workflow, check its Outputs for the "Call cities endpoint" data:

The "call cities endpoint" data appears in the Output of the Workflow.

Last updated

Was this helpful?