Apache APISIX is a dynamic and high-performance API Gateway that can manage your traffic efficiently with features like load balancing, canary releases, and authentication. In this guide, we will walk you through how to run Apache APISIX in both stand-alone mode and using etcd as a configuration center.
What is Apache APISIX?
APISIX is designed to handle both traditional north-south traffic and east-west traffic between services. It is already being used by organizations like NASA, Tencent Cloud, and Airwallex among others. Now, let’s learn how to set it up!
Running APISIX in Stand-Alone Mode
In stand-alone mode, APISIX uses apisix.yaml for routing and configuration storage. After starting, APISIX will regularly load this file to keep configurations up to date.
Steps to Start APISIX Container
- Use the following command to start APISIX in stand-alone mode:
docker run -d --name apache-apisix -p 9080:9080 -e APISIX_STAND_ALONE=true apache/apisix
Adding Route and Plugin Configuration
- Execute the command to add routing and plugin configuration:
docker exec -i apache-apisix sh -c cat /usr/local/apisix/conf/apisix.yaml <<- _END_EOC_
routes:
- id: httpbin
uri: *
upstream:
nodes:
httpbin.org: 1
type: roundrobin
plugin_config_id: 1
plugin_configs:
- id: 1
plugins:
response-rewrite:
body: Hello APISIX
desc: response-rewrite
_END_EOC_
Testing the Setup
Check if everything is running smoothly by sending a curl request:
curl http://127.0.0.1:9080
If successful, you should receive the response: Hello APISIX.
Running APISIX Using etcd as Configuration Center
Solution 1: Using Host Network
- Start by running the etcd container with:
docker run -d --name etcd --net host -e ALLOW_NONE_AUTHENTICATION=yes -e ETCD_ADVERTISE_CLIENT_URLS=http://127.0.0.1:2379 bitnami/etcd:latest
- Next, run the APISIX container:
docker run -d --name apache-apisix --net host apache/apisix
Solution 2: Using Docker Virtual Network
- Create a Docker network:
docker network create apisix-network --driver bridge
- Then start the etcd container:
docker run -d --name etcd --network apisix-network -p 2379:2379 -p 2380:2380 -e ALLOW_NONE_AUTHENTICATION=yes -e ETCD_ADVERTISE_CLIENT_URLS=http://127.0.0.1:2379 bitnami/etcd:latest
- Lastly, create a configuration file and run APISIX:
cat < $(pwd)/config.yaml
deployment:
role: traditional
role_traditional:
config_provider: etcd
admin:
allow_admin:
- 0.0.0.0/0
etcd:
host:
- http://etcd:2379
prefix: apisix
timeout: 30
EOF
docker run -d --name apache-apisix --network apisix-network -p 9080:9080 -p 9180:9180 -v $(pwd)/config.yaml:/usr/local/apisix/conf/config.yaml apache/apisix
Test Example
Confirm APISIX is operational:
curl http://127.0.0.1:9180/apisix/admin/services -H X-API-KEY:edd1c9f034335f136f87ad84b625c8f1
You should see a response indicating that APISIX is functioning correctly.
Reloading APISIX in a Running Container
If you modify your configuration, you can reload APISIX without downtime by using:
docker exec -it apache-apisix apisix reload
Troubleshooting Ideas
Should you encounter issues, consider these tips:
- Ensure all necessary ports are open and not in use by other applications.
- Check the logs for APISIX and etcd for any error messages.
- Make sure the configuration files are formatted correctly and all required fields are set.
If you need further assistance, visit us at **[fxis.ai](https://fxis.ai/edu)** for insights, updates, or to collaborate on AI development projects.
Kubernetes Ingress
If you're deploying on Kubernetes, you can utilize the apisix-ingress-controller for an even smoother experience.
Final Thoughts
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.
Conclusion
With this guide, you should be equipped to run Apache APISIX in both stand-alone mode and using etcd as a configuration center. The potential of APISIX in managing API traffic is immense, making it a pivotal tool in modern web architecture.

