使用traefik 1.5-rc3设置使用docker后端标签设置rateimiting时遇到问题
设置以下标签
# enable rate limitation on frontend per IP. 5 Request avg per 3s, 15 Reqs in a row
# see https://github.com/containous/traefik/blob/v1.5/docs/configuration/commons.md#rate-limiting
- "traefik.frontend.rateLimit.extractorFunc=client.ip"
- "traefik.frontend.rateLimit.rateSet.r1.period=3s"
- "traefik.frontend.rateLimit.rateSet.r1.average=5"
- "traefik.frontend.rateLimit.rateSet.r1.burst=15"
- "traefik.frontend.rateLimit.rateSet.r2.period=10s"
- "traefik.frontend.rateLimit.rateSet.r2.average=50"
- "traefik.frontend.rateLimit.rateSet.r2.burst=100"
不会在日志文件中打印任何速率限制输出,也不会显示配置,例如在/api
前端结构中:
没有错误消息或任何内容:
time="2018-01-17T16:11:08Z" level=debug msg="Could not load traefik.frontend.whitelistSourceRange labels"
time="2018-01-17T16:11:08Z" level=debug msg="Could not load traefik.frontend.auth.basic labels"
time="2018-01-17T16:11:08Z" level=debug msg="Validation of load balancer method for backend backend-xxx-xxx-1-xxx-xxxx-default failed: invalid load-balancing method ''. Using default method wrr."
time="2018-01-17T16:11:08Z" level=debug msg="Configuration received from provider docker: {"backends":{"backend-xxx-xxx-1-xxx-xxx-default":{"servers":{"service-0":{"url":"http://172.20.0.5:3000","weight":0}},"loadBalancer":{"method":"wrr"}},"backend-xxx-xxx":{"loadBalancer":{"method":"wrr"},"maxConn":{"amount":10,"extractorFunc":"request.host"}}},"frontends":{"frontend-xxx-xxx-1-xxx-xxx-default":{"entryPoints":["http"],"backend":"backend-xxx-xxx-1-xxx-xxx-default","routes":{"service-default":{"rule":"Host:localhost"}},"passHostHeader":true,"priority":0,"basicAuth":[]}}}"
静态配置中的相同配置toml:
[frontends.xxx.ratelimit]
extractorfunc = "client.ip"
[frontends.xxx.ratelimit.rateset.rateset1]
period = "10s"
average = 100
burst = 200
[frontends.xxx.ratelimit.rateset.rateset2]
period = "3s"
average = 5
burst = 10
似乎有效,因为日志记录状态为Creating load-balancer rate limiter
:
{"loadBalancer":{"method":"wrr"}}},"frontends":{"xxx":{"entryPoints":["http"],"backend":"xxx","routes":{"test_1":{"rule":"Host:xxx,localhost"}},"priority":0,"basicAuth":null,"ratelimit":{"rateset":{"rateset1":{"period":10000000000,"average":100,"burst":200},"rateset2":{"period":3000000000,"average":5,"burst":10}},"extractorFunc":"client.ip"}}}}"
...
time="2018-01-17T16:11:08Z" level=debug msg="Creating backend xxx"
time="2018-01-17T16:11:08Z" level=debug msg="Creating load-balancer wrr"
time="2018-01-17T16:11:08Z" level=debug msg="Creating load-balancer rate limiter"
time="2018-01-17T16:11:08Z" level=debug msg="Creating retries max attempts 0"
查看source-code标签似乎没问题。
我错过了什么?我刚才注意到,解析方法中的extractorfunc(backend)和extractorFunc(frontend)上的不同大小。
通过标签设置费率限制需要做些什么?
答案 0 :(得分:0)
您正在观看的公关(https://github.com/containous/traefik/pull/2584)适用于1.6。
您可以在PR的里程碑部分看到该版本。