HTTP Router and Reverse Proxy | HTTP 路由器和反向代理
Skipper 是一个强大的 HTTP 路由器和反向代理,由 Zalando 开发并开源,专为服务组合和高性能场景设计,包括 Kubernetes Ingress 等用例。
可处理大规模动态路由配置,生产环境支持超过 80 万条路由,每秒 6 万次请求
使用 eskip 格式配置路由,支持丰富的过滤器和谓词
支持路径重写、限流、请求修改、负载均衡等多种功能
内置 Prometheus 指标支持,方便监控和分析
点击以下链接测试已配置的路由:
在 Lazycat 平台上,路由配置文件位于:
/data/appvar/cloud.lazycat.app.liu.skipper/config/routes.eskip
路由使用 eskip 格式配置,基本语法:
ID: Predicate() -> filter() -> BACKEND
将请求代理到后端服务:
google: Path("/google") -> "https://www.google.com";
返回静态内容,无需后端服务:
hello: Path("/hello") -> inlineContent("Hello World!") -> <shunt>;
修改请求路径后转发:
api: Path("/api/*path") -> modPath("^/api", "") -> "https://api.example.com";
为请求添加自定义头部:
headers: Path("/test") -> setRequestHeader("X-Custom", "value") -> "https://backend.com";
限制客户端请求频率(每分钟 100 次):
limited: Path("/limited") -> clientRatelimit(100, "1m") -> "https://backend.com";
添加健康检查端点:
health: Path("/health") -> inlineContent("OK") -> <shunt>;
使用以下命令测试你的路由配置:
# 测试 Hello World 路由
curl https://your-domain.com/hello
# 测试代理路由
curl https://your-domain.com/google
# 测试 API 代理
curl https://your-domain.com/api/users
Skipper 支持端口(9911)提供管理功能:
# 查看所有加载的路由
curl http://your-domain.com:9911/routes
# 查看 Prometheus 指标(如果启用)
curl http://your-domain.com:9911/metrics
/data/appvar/cloud.lazycat.app.liu.skipper/config/routes.eskip通过环境变量启用指标收集:
SKIPPER_EXTRA_ARGS=-enable-prometheus-metrics
然后通过管理端口访问 http://your-domain.com:9911/metrics 查看指标。
添加访问日志记录:
SKIPPER_EXTRA_ARGS=-access-log-disabled=false
配置多个后端服务的负载均衡:
lb: Path("/app") -> lbBackend("http://backend1:8080", "http://backend2:8080");
Skipper is a powerful HTTP router and reverse proxy developed and open-sourced by Zalando, designed for service composition and high-performance scenarios, including use cases like Kubernetes Ingress.
Handles large-scale dynamic routing configurations, supporting over 800,000 routes and 60,000 requests per second in production
Configure routes using eskip format with rich filters and predicates
Supports path rewriting, rate limiting, request modification, load balancing, and more
Built-in Prometheus metrics support for easy monitoring and analysis
Click the links below to test configured routes:
On Lazycat platform, the routing configuration file is located at:
/data/appvar/cloud.lazycat.app.liu.skipper/config/routes.eskip
Routes are configured using eskip format, basic syntax:
ID: Predicate() -> filter() -> BACKEND
Proxy requests to a backend service:
google: Path("/google") -> "https://www.google.com";
Return static content without a backend service:
hello: Path("/hello") -> inlineContent("Hello World!") -> <shunt>;
Modify request path before forwarding:
api: Path("/api/*path") -> modPath("^/api", "") -> "https://api.example.com";
Add custom headers to requests:
headers: Path("/test") -> setRequestHeader("X-Custom", "value") -> "https://backend.com";
Limit client request frequency (100 requests per minute):
limited: Path("/limited") -> clientRatelimit(100, "1m") -> "https://backend.com";
Add health check endpoint:
health: Path("/health") -> inlineContent("OK") -> <shunt>;
Use the following commands to test your routing configuration:
# Test Hello World route
curl https://your-domain.com/hello
# Test proxy route
curl https://your-domain.com/google
# Test API proxy
curl https://your-domain.com/api/users
Skipper support port (9911) provides management features:
# View all loaded routes
curl http://your-domain.com:9911/routes
# View Prometheus metrics (if enabled)
curl http://your-domain.com:9911/metrics
/data/appvar/cloud.lazycat.app.liu.skipper/config/routes.eskipEnable metrics collection via environment variable:
SKIPPER_EXTRA_ARGS=-enable-prometheus-metrics
Then access http://your-domain.com:9911/metrics through the admin port to view metrics.
Add access log recording:
SKIPPER_EXTRA_ARGS=-access-log-disabled=false
Configure load balancing across multiple backend services:
lb: Path("/app") -> lbBackend("http://backend1:8080", "http://backend2:8080");
For more detailed configuration and features, please refer to the official documentation: