---
schema_version: "1"
id: 6bb5a370f101abb1db4894cb75c9bb2a41712deb24714076e849cb8ece8b22df
title: Getting Started with Self-Managed Flex Gateway
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/gateway/1.12/flex-gateway-getting-started.md
canonical_url: https://docs.mulesoft.com/gateway/1.12/flex-gateway-getting-started
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 016ba40c66ec73ed0a107c150243c8dcf5b71dc7906b162907fe4f19463384ce
description: MuleSoft Documentation Site
release: "1.12"
latest: false
---
---
product: Omni Gateway
version: 1.12
---

# Getting Started with Self-Managed Flex Gateway

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The goal of this tutorial is to quickly get started with Anypoint Flex Gateway. Using Docker, the
tutorial describes how to install, register, and run Flex Gateway in Connected Mode. 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:

- A username and password for your Anypoint Platform organization. If you don’t have Anypoint
  Platform yet, [create a Trial organization](https://anypoint.mulesoft.com/login/signup) on
  Anypoint Platform.

- A Linux machine with an x86 processor. M1 and M2 processors are not supported.

  Flex Gateway runs on the following Long Term Support (LTS) versions of Linux:

  - Amazon Linux 2023

  - CentOS 8

  - Debian Bookworm

  - Red Hat Enterprise Linux (9)

  - Red Hat Enterprise Linux (9) on IBM Power (ppc64le)

  - Ubuntu Jammy

- A Docker installation. See [Docker Desktop](https://www.docker.com/products/docker-desktop/) for
  an example.

## Download Flex Gateway

To download the Flex Gateway Docker image, run the following command in a terminal window:

```ssh
docker pull mulesoft/flex-gateway:latest
```

> [!NOTE] Use `sudo` if you encounter file permission issues when running this command.

## Register Flex Gateway

1.  Create a new directory by running:

    ```ssh
    mkdir flex-registration
    ```

2.  Navigate to the new directory by running:

    ```ssh
    cd flex-registration
    ```

3.  Log in to [Anypoint Platform](https://anypoint.mulesoft.com/login/) with your Anypoint username
    and password.

4.  Select **Runtime Manager**.

5.  Click **Flex Gateways** in the side navigation panel.

6.  Click **Self-managed Flex Gateways**.

7.  Click **Add Gateway**.

8.  Select **Docker**.

9.  Copy the code block in the **Register your gateway** section. The code block contains your
    unique organization ID and token.

    The following screenshot of the **Add a Flex Gateway** page highlights the code block to copy:

    ![A code block with a command to register a Flex Gateway with Anypoint Platform](/mulesoft/current/en-us/gateway/1.12/_images/gateway-quickstart-add-gateway.png)

10. Run the copied code block in your terminal window, making sure to first replace `<gateway-name>`
    with a name, such as `my-gw`.

    > [!NOTE] Use `sudo` if you encounter file permission issues when running this command.

11. In Runtime Manager, select **Flex Gateways** from the side navigation panel.

    Your registered Flex Gateway now appears in the list of gateways.

## Run Flex Gateway

To run Flex Gateway, run the following in a terminal window:

```ssh
docker run --rm \
  -v "$(pwd)":/usr/local/share/mulesoft/flex-gateway/conf.d \
  -p 8081:8081 \
  mulesoft/flex-gateway
```

> [!NOTE] Use `sudo` if you encounter file permission issues when running this command.

A new Flex Gateway instance is now running in your terminal window.

> [!NOTE] The Flex Gateway instance will continue running in the terminal window until the process
> is stopped, or until the window is closed.

## Publish a Simple API

1.  Select **API Manager** from the Anypoint Platform menu.

2.  Click **Add API** > **Add new API**.

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

4.  Select your registered gateway in the **Select a gateway** section.

5.  Click **Next**.

6.  Click **Create New API**.

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

8.  Click **Next**.

9.  From the **Endpoint** page, enter the following in the **Implementation URI** field:

    ```none
    https://jsonplaceholder.typicode.com/
    ```

10. Enter `8081` in the **Port** field.

11. Click **Next**.

12. Click **Save & Deploy**.

    Inside the gateway instance Docker container, all HTTP requests made to `localhost` on port
    `8081` are now proxied to the `jsonplaceholder` service.

13. To test the API Instance, run the following command in a new terminal window:

    ```ssh
    curl -s -o /dev/null -w "%{http_code}\n" --request GET 'http://localhost:8081/'
    ```

    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.  While still in **API Manager**, select **API Instances** from the side navigation panel.

2.  Select the name of the API created in the previous section.

3.  Select **Policies** from the side navigation panel.

4.  In the **Policies** page, click **Add policy**.

    The following screenshot of the **Policies** page highlights the specified options:

    ![Add Policy page with Add policy button](/mulesoft/current/en-us/gateway/1.12/_images/gateway-quickstart-add-policy.png)

5.  Select the **Basic Authentication - Simple** policy.

6.  Click **Next**.

7.  For **User Name**, enter `user`.

8.  For **User Password**, enter `password`.

9.  Click **Apply**.

    The following screenshot of the **Configure Basic Authentication - Simple policy** page
    highlights the specified options:

    ![Configure Basic Authentication Policy page with User Password field selected](/mulesoft/current/en-us/gateway/1.12/_images/gateway-quickstart-config-basic-auth.png)

10. To test the API Instance _without_ authentication, run the following `curl` command in the
    terminal window:

    ```ssh
    curl -s -o /dev/null -w "%{http_code}\n" --request GET 'http://localhost:8081/'
    ```

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

11. To test the API Instance _with_ authentication, run the following command in the terminal
    window:

    ```ssh
    curl -s -o /dev/null -w "%{http_code}\n" --request GET 'http://localhost:8081/' -u user:password
    ```

    > [!NOTE] 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.

## Next Steps

- [Requirements and Limits for Flex Gateway](https://docs.mulesoft.com/gateway/1.12/flex-review-prerequisites)

- [Setting Up Self-Managed Flex Gateway](https://docs.mulesoft.com/gateway/1.12/flex-gateway-set-up)
