A unified API Gateway built with Spring Cloud Gateway that supports routing for:
- ✅ REST APIs (HTTP/1.1)
- ✅ gRPC Services (HTTP/2 + TLS)
- ✅ Web Applications (React etc.)
- ✅ Custom Filters
- ✅ SSL / mTLS Support
- ✅ Load Balancing Ready
┌─────────────────────┐
│ React App │
│ (Frontend SPA) │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Spring Cloud │
│ Gateway │
│ (HTTP1 + HTTP2) │
└───────┬───────┬─────┘
│ │
▼ ▼
┌──────────┐ ┌──────────┐
│ REST │ │ gRPC │
│ Service │ │ Service │
└──────────┘ └──────────┘
- ☕ Java 25
- ⚡ Gradle
- 🌱 Spring Boot
- 🌐 Spring Cloud Gateway
- 🔄 Reactor Netty
- 📡 REST (HTTP/1)
- 📡 gRPC (HTTP/2)
- 🔐 TLS / SSL (PKCS12 / JKS / PEM)
- Path-based routing
- Load balancing support
- Custom filters
- Header manipulation
- Authentication ready
Example:
GET /api/users
→ Forward to http://localhost:8081- HTTP/2 support
- TLS secured channel
- Custom
ServerWebExchangeURI rewriting - Supports internal PKCS12 bundle
- Compatible with
spring-grpcor Netty server
Example:
service UserService {
rpc GetUser(UserRequest) returns (UserResponse);
}Gateway forwards:
https://gateway:9090/grpc/UserService
→ https://localhost:50051
- SPA routing support
- Static content proxy
- Supports HTTPS certificates
- Works with custom SSL setup
Example:
https://gateway:9090/app
→ https://localhost:3000
Supports:
- PKCS12 (
.p12) - JKS
- PEM (
.crt+.key) - Self-signed certificates
- mTLS (optional)
Example application.properties:
server.port=9090
server.ssl.enabled=true
server.ssl.key-store=classpath:gateway.p12
server.ssl.key-store-password=changeit
server.ssl.key-store-type=PKCS12
server.http2.enabled=truespring-cloud-gateway/
│
├── src/main/java/
│ ├── config/
│ ├── filter/
│ ├── route/
│ └── GatewayApplication.java
│
├── src/main/resources/
│ ├── application.properties
│ └── ssl/
│
└── build.gradle
@Component
public class GrpcRoutingFilter implements GlobalFilter, Ordered {
@Override
public Mono<Void> filter(ServerWebExchange exchange,
GatewayFilterChain chain) {
URI newUri = URI.create("https://localhost:50051");
exchange.getAttributes()
.put(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR, newUri);
return chain.filter(exchange);
}
@Override
public int getOrder() {
return -1;
}
}./gradlew clean build./gradlew bootRunor
java -jar build/libs/gateway.jarPull requests are welcome!
MIT License