Apache APISIX Gateway
Cloud-native API gateway with APISIX, etcd backend, Dashboard UI, and Grafana monitoring.
Overview
Apache APISIX is a cloud-native, high-performance API gateway built on OpenResty/Nginx and etcd. Launched by the Apache Software Foundation, APISIX provides dynamic routing, load balancing, and comprehensive plugin ecosystem with over 80 plugins for authentication, security, observability, and traffic management. Unlike traditional API gateways that require restarts for configuration changes, APISIX offers hot-reloading capabilities and real-time configuration updates through its etcd backend.
This production-grade stack combines APISIX's core gateway functionality with etcd for distributed configuration storage, the APISIX Dashboard for web-based management, Prometheus for metrics collection, and Grafana for visualization. The etcd cluster serves as APISIX's control plane, storing route configurations, plugin settings, and upstream definitions with strong consistency guarantees. Prometheus scrapes metrics from APISIX's built-in metrics endpoint, while Grafana provides rich dashboards for monitoring API traffic, latency, error rates, and plugin performance.
This configuration targets platform engineers, API architects, and DevOps teams building microservices infrastructures that require dynamic traffic management, comprehensive observability, and plugin-based extensibility. The stack excels in environments demanding frequent routing changes, A/B testing capabilities, and granular traffic control without service interruptions.
Key Features
- Dynamic routing and upstream management without gateway restarts through etcd-based configuration
- 80+ built-in plugins including JWT authentication, rate limiting, circuit breakers, and custom Lua scripting
- Real-time traffic splitting and canary deployments with percentage-based routing rules
- APISIX Dashboard web interface for visual route management, plugin configuration, and upstream health monitoring
- Native Prometheus metrics export with detailed API gateway performance, plugin execution times, and traffic patterns
- etcd clustering for high availability configuration storage with automatic leader election and data replication
- WebSocket and gRPC protocol support alongside traditional HTTP/HTTPS with SSL termination
- Built-in service discovery integration with Consul, DNS, and Kubernetes for automatic upstream detection
Common Use Cases
- 1Microservices API gateway for Kubernetes clusters requiring dynamic service routing and plugin-based traffic policies
- 2Multi-tenant SaaS platforms needing per-tenant rate limiting, authentication, and custom routing logic
- 3E-commerce platforms implementing A/B testing, canary deployments, and traffic splitting for new features
- 4Enterprise API management with centralized logging, metrics collection, and security policy enforcement
- 5Edge computing deployments requiring lightweight, high-performance traffic management with real-time configuration updates
- 6Development environments needing rapid API prototyping, mock responses, and traffic simulation capabilities
- 7Legacy system modernization providing API abstraction layer with gradual migration support and traffic mirroring
Prerequisites
- Minimum 2GB RAM (APISIX: 512MB, etcd: 512MB, Grafana: 512MB, Prometheus: 1GB for metrics retention)
- Docker Engine 20.10+ and Docker Compose 2.0+ with overlay network support for multi-container communication
- Available ports 9080, 9443, 9000, 9090, 3000 for APISIX gateway, dashboard, and monitoring interfaces
- Basic understanding of API gateway concepts, REST routing, and plugin-based architecture patterns
- Familiarity with YAML configuration syntax for APISIX routes, upstreams, and plugin definitions
- Knowledge of PromQL query language for creating custom Grafana dashboards and Prometheus alerting rules
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 apisix: 3 image: apache/apisix:latest4 ports: 5 - "9080:9080"6 - "9443:9443"7 - "9091:9091"8 - "9092:9092"9 volumes: 10 - ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro11 depends_on: 12 - etcd13 networks: 14 - apisix-net15 restart: unless-stopped1617 etcd: 18 image: bitnami/etcd:latest19 environment: 20 ETCD_ENABLE_V2: "true"21 ALLOW_NONE_AUTHENTICATION: "yes"22 ETCD_ADVERTISE_CLIENT_URLS: http://etcd:237923 ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:237924 volumes: 25 - etcd_data:/bitnami/etcd26 networks: 27 - apisix-net28 restart: unless-stopped2930 apisix-dashboard: 31 image: apache/apisix-dashboard:latest32 ports: 33 - "9000:9000"34 volumes: 35 - ./dashboard_conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml:ro36 depends_on: 37 - apisix38 networks: 39 - apisix-net40 restart: unless-stopped4142 prometheus: 43 image: prom/prometheus:latest44 ports: 45 - "9090:9090"46 volumes: 47 - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro48 - prometheus_data:/prometheus49 networks: 50 - apisix-net51 restart: unless-stopped5253 grafana: 54 image: grafana/grafana:latest55 ports: 56 - "3000:3000"57 environment: 58 GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}59 volumes: 60 - grafana_data:/var/lib/grafana61 networks: 62 - apisix-net63 restart: unless-stopped6465volumes: 66 etcd_data: 67 prometheus_data: 68 grafana_data: 6970networks: 71 apisix-net: 72 driver: bridge.env Template
.env
1# Grafana2GRAFANA_PASSWORD=secure_grafana_password34# APISIX Dashboard Credentials5DASHBOARD_USERNAME=admin6DASHBOARD_PASSWORD=adminUsage Notes
- 1APISIX Gateway at http://localhost:9080
- 2Dashboard at http://localhost:9000
- 3Default login: admin / admin
- 4Supports 80+ plugins out of box
Individual Services(5 services)
Copy individual services to mix and match with your existing compose files.
apisix
apisix:
image: apache/apisix:latest
ports:
- "9080:9080"
- "9443:9443"
- "9091:9091"
- "9092:9092"
volumes:
- ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro
depends_on:
- etcd
networks:
- apisix-net
restart: unless-stopped
etcd
etcd:
image: bitnami/etcd:latest
environment:
ETCD_ENABLE_V2: "true"
ALLOW_NONE_AUTHENTICATION: "yes"
ETCD_ADVERTISE_CLIENT_URLS: http://etcd:2379
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
volumes:
- etcd_data:/bitnami/etcd
networks:
- apisix-net
restart: unless-stopped
apisix-dashboard
apisix-dashboard:
image: apache/apisix-dashboard:latest
ports:
- "9000:9000"
volumes:
- ./dashboard_conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml:ro
depends_on:
- apisix
networks:
- apisix-net
restart: unless-stopped
prometheus
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks:
- apisix-net
restart: unless-stopped
grafana
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
volumes:
- grafana_data:/var/lib/grafana
networks:
- apisix-net
restart: unless-stopped
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 apisix:5 image: apache/apisix:latest6 ports:7 - "9080:9080"8 - "9443:9443"9 - "9091:9091"10 - "9092:9092"11 volumes:12 - ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro13 depends_on:14 - etcd15 networks:16 - apisix-net17 restart: unless-stopped1819 etcd:20 image: bitnami/etcd:latest21 environment:22 ETCD_ENABLE_V2: "true"23 ALLOW_NONE_AUTHENTICATION: "yes"24 ETCD_ADVERTISE_CLIENT_URLS: http://etcd:237925 ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:237926 volumes:27 - etcd_data:/bitnami/etcd28 networks:29 - apisix-net30 restart: unless-stopped3132 apisix-dashboard:33 image: apache/apisix-dashboard:latest34 ports:35 - "9000:9000"36 volumes:37 - ./dashboard_conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml:ro38 depends_on:39 - apisix40 networks:41 - apisix-net42 restart: unless-stopped4344 prometheus:45 image: prom/prometheus:latest46 ports:47 - "9090:9090"48 volumes:49 - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro50 - prometheus_data:/prometheus51 networks:52 - apisix-net53 restart: unless-stopped5455 grafana:56 image: grafana/grafana:latest57 ports:58 - "3000:3000"59 environment:60 GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}61 volumes:62 - grafana_data:/var/lib/grafana63 networks:64 - apisix-net65 restart: unless-stopped6667volumes:68 etcd_data:69 prometheus_data:70 grafana_data:7172networks:73 apisix-net:74 driver: bridge75EOF7677# 2. Create the .env file78cat > .env << 'EOF'79# Grafana80GRAFANA_PASSWORD=secure_grafana_password8182# APISIX Dashboard Credentials83DASHBOARD_USERNAME=admin84DASHBOARD_PASSWORD=admin85EOF8687# 3. Start the services88docker compose up -d8990# 4. View logs91docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/apisix-gateway-stack/run | bashTroubleshooting
- APISIX fails to start with 'etcd connection refused': Ensure etcd container is fully initialized before APISIX starts, add health check or delay
- Dashboard shows 'failed to fetch routes' error: Verify APISIX admin API is accessible on port 9091 and admin_key matches between config files
- 502 Bad Gateway on API requests: Check upstream service availability and ensure upstream definitions in APISIX point to correct backend services
- Prometheus shows no APISIX metrics: Enable prometheus plugin in APISIX config.yaml and verify metrics endpoint accessibility on port 9091/apisix/prometheus/metrics
- etcd data loss after container restart: Ensure etcd_data volume is properly mounted and ETCD_DATA_DIR environment variable points to persistent storage
- Plugin configuration changes not taking effect: Verify etcd connectivity and check APISIX error logs for plugin validation failures or syntax errors
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
apisixapisix-dashboardetcdprometheusgrafana
Tags
#apisix#api-gateway#cloud-native#etcd#plugins
Category
DevOps & CI/CDAd Space
Shortcuts: C CopyF FavoriteD Download