APISIX GATEWAY Configuration and Route Orchestration

Edison Devadoss
YavarTechWorks
Published in
3 min readDec 14, 2023

--

In this post, I will explain the APISIX gateway and how it orchestrates APIs.

What is the APISIX?

APISIX is an open-source API Gateway to help you manage microservices, Authentication, Observability, and traffic management features like Load Balancing, Dynamic Upstream, etc.

Where I used APISIX in real-time:

I faced a situation where I had three separate backend applications. Each application is a separate stand-alone and each has its authentication & authorization.

But instead of three front-end applications, I need to have only one front-end application. Challenges I faced in accomplishing this,

  • It should have only one Login feature.
  • Three applications should accept a single token.
  • User management in three applications.

To overcome these challenges, I used two tools, Keycloak(SSO), and APISIX for orchestration.

I used Keycloak for centralized authentication and authorisation and APISIX for API orchestration.

The front-end application should know only the APISIX backend URL. APISIX have a dashboard, and using that dashboard I configure routes. APISIX route the API to the respective backend application.

APISIX Installation:

For installing APISIX we need to install three services (etcd, apisix and apisix-dashboard). We can install these services in several ways, but I installed them through Docker.

etcd installation:

etc is a strongly consistent, distributed key-value store that provides a reliable way to store data that needs to be accessed by a distributed system or cluster of machines.

  docker run -d \
--restart unless-stopped \
--name etcd \
--network=host \
-e ALLOW_NONE_AUTHENTICATION=yes \
-e ETCD_ADVERTISE_CLIENT_URLS=http://127.0.0.1:2379 \
bitnami/etcd:latest

Apache APISIX installation:

  docker run -d \
--restart unless-stopped \
--name apache-apisix \
--network=host \
apache/apisix

APISIX dashboard installation:

docker run --network=host -d \
--restart unless-stopped \
--name dashboard \
-p 9000:9000 \
-v <CONFIG_FILE>:/usr/local/apisix-dashboard/conf/conf.yaml \
apache/apisix-dashboard

CONFIG_FILE — We need to give conf.yaml file with our configuration. Sample configuration here to download and create a file in our system and give an absolute path.

— — network=host — This line we can see in all three installations. Because of this, the docker container can access the services which are running outside the docker.

After completion of installation verify whether all the containers are running or not. If all three containers are running then you can access your APISIX dashboard and configure routes.

Access APISIX dashboard:

Now I can access the API dashboard in localhost:9000. By default the username is admin and the password is admin.

Configure a route:

I run a node application in 5000 port and I have route GET /ip. APISIX redirect to node application /ip method. We can see the route configuration in the below image.

Output:

In my browser, I just enter http://localhost:9080/ip it hits my backend application which runs in port 5000. http://localhost:9080 This URL is for the APISIX backend. Using this our frontend application should access the route.

You can see the sample output below.

Thank you for reading. Have a nice day!

--

--

Edison Devadoss
YavarTechWorks

Software developer / JavaScript / React / React Native / Firebase / Node.js / C Programming / Book Reader