When you have multiple microservices, how do you manage routing, security, rate limiting, and incoming traffic without duplicating the same logic across every service?
In our microservices architecture, we use Apache APISIX as a centralized API Gateway to manage incoming requests and route them to the appropriate Spring Boot services.
Rather than exposing every microservice directly to clients, we provide a single entry point where common traffic management and edge security policies are enforced.
Here's how we implemented it.
1. Centralized API Routing
Our request flow looks like this:
Client ? Apache APISIX ? Spring Boot Microservice
We use path-based routing to forward requests to their corresponding backend services.
For example:
/api/projects/*? Project Service/api/inspections/*? Inspection Service/api/tasks/*? Task Management Service
Clients interact with a consistent API entry point without needing to know the internal service addresses.
2. IP-Based Access Control
We use the APISIX ip-restriction plugin to manage access based on IP addresses and CIDR ranges.
In development, we allow requests from all IP addresses to simplify testing.
In production, we can restrict selected routes to trusted networks.
Lesson: Security policies should be environment-aware, and production access should follow the principle of least privilege.
3. Load Balancing with Round Robin
We configure APISIX upstreams using the roundrobin algorithm.
Some of our services currently run as single instances, but the configuration allows us to register multiple backend instances as we scale.
When multiple instances are available, APISIX distributes incoming requests among them.
This helps support horizontal scaling without changing the client-facing API.
4. Centralized CORS Management
Instead of configuring cross-origin policies independently across every service, we manage shared CORS policies at the gateway.
These include:
- Allowed frontend origins
- HTTP methods and request headers
- Exposed response headers
- Credential support
This simplifies frontend-to-backend communication while keeping cross-origin access controlled.
5. Rate Limiting to Protect Backend Services
We use the APISIX limit-count plugin to enforce request limits.
Our configuration allows:
120 requests per minute per client IP
Requests exceeding the configured threshold receive:
HTTP 429 Too Many Requests
Currently, the counter is maintained locally by each gateway instance.
For multiple gateway replicas, a shared counter strategy would be needed to enforce a consistent global limit.
Lesson: Rate limiting is not just about protecting APIs from abuse. It also helps prevent excessive traffic from overwhelming backend services.
6. URL Rewriting
Public API paths do not always need to match internal service endpoint structures.
For example:
Public endpoint:
/api/task-service/*
Internal endpoint:
/api/v1/task-service/*
We use APISIX URL rewriting to transform incoming paths before forwarding requests.
This gives us flexibility to evolve internal API structures while maintaining stable public routes.
7. Security Response Headers
We configure common browser security headers at the gateway, including:
X-Content-Type-Options: nosniffX-Frame-Options: DENYReferrer-Policy
These provide additional browser-side protections without requiring repetitive configuration in every microservice.
8. Configuration as Code
One of the most useful aspects of our implementation is managing gateway configuration declaratively.
We run Apache APISIX in standalone mode using YAML configuration.
Our deployment environments include:
Docker Compose — Local development and testing
Kubernetes — Container orchestration and deployment
This makes gateway configuration easier to version, review, and maintain alongside application infrastructure.
An Important Architectural Decision
The API Gateway should not become another business-logic service.
We maintain a clear separation of responsibilities.
Apache APISIX handles:
- API routing and URL rewriting
- Load balancing
- Rate limiting
- CORS and IP restrictions
- Shared edge security policies
Spring Boot microservices handle:
- Authentication and authorization
- Business rules and request validation
- Domain-specific operations
- Database access and data management
This separation keeps our microservices independently maintainable while centralizing common traffic concerns.
Key Takeaway
An API Gateway is more than a reverse proxy.
It becomes an important architectural component for managing traffic, applying consistent policies, and simplifying communication between clients and distributed backend systems.
Our experience with Apache APISIX reinforces an important principle:
Centralize cross-cutting infrastructure concerns, but keep business logic and domain security within the services that own them.

Join the discussion
Ask a question or share what you learned. Comments are reviewed before appearing.