Disable RateLimit temporarily

This commit is contained in:
Julien Salleyron 2019-07-19 10:50:05 +02:00 committed by Traefiker Bot
parent d5f4934acf
commit e3627e9cba
12 changed files with 122 additions and 144 deletions

View file

@ -1,5 +1,8 @@
# RateLimit
!!! warning
This middleware is disable for now.
Protection from Too Many Calls
{: .subtitle }

View file

@ -186,18 +186,6 @@
commonName = true
serialNumber = true
domainComponent = true
[http.middlewares.Middleware13]
[http.middlewares.Middleware13.rateLimit]
extractorFunc = "foobar"
[http.middlewares.Middleware13.rateLimit.rateSet]
[http.middlewares.Middleware13.rateLimit.rateSet.Rate0]
period = "42ns"
average = 42
burst = 42
[http.middlewares.Middleware13.rateLimit.rateSet.Rate1]
period = "42ns"
average = 42
burst = 42
[http.middlewares.Middleware14]
[http.middlewares.Middleware14.redirectRegex]
regex = "foobar"

View file

@ -212,18 +212,6 @@ http:
commonName: true
serialNumber: true
domainComponent: true
Middleware13:
rateLimit:
rateSet:
Rate0:
period: 42ns
average: 42
burst: 42
Rate1:
period: 42ns
average: 42
burst: 42
extractorFunc: foobar
Middleware14:
redirectRegex:
regex: foobar

View file

@ -83,13 +83,6 @@
- "traefik.http.middlewares.middleware12.passtlsclientcert.info.subject.province=true"
- "traefik.http.middlewares.middleware12.passtlsclientcert.info.subject.serialnumber=true"
- "traefik.http.middlewares.middleware12.passtlsclientcert.pem=true"
- "traefik.http.middlewares.middleware13.ratelimit.extractorfunc=foobar"
- "traefik.http.middlewares.middleware13.ratelimit.rateset.rate0.average=42"
- "traefik.http.middlewares.middleware13.ratelimit.rateset.rate0.burst=42"
- "traefik.http.middlewares.middleware13.ratelimit.rateset.rate0.period=42"
- "traefik.http.middlewares.middleware13.ratelimit.rateset.rate1.average=42"
- "traefik.http.middlewares.middleware13.ratelimit.rateset.rate1.burst=42"
- "traefik.http.middlewares.middleware13.ratelimit.rateset.rate1.period=42"
- "traefik.http.middlewares.middleware14.redirectregex.permanent=true"
- "traefik.http.middlewares.middleware14.redirectregex.regex=foobar"
- "traefik.http.middlewares.middleware14.redirectregex.replacement=foobar"

View file

@ -309,6 +309,8 @@ func (s *AccessLogSuite) TestAccessLogFrontendRedirect(c *check.C) {
}
func (s *AccessLogSuite) TestAccessLogRateLimit(c *check.C) {
c.Skip("RateLimit is disable for now")
ensureWorkingDirectoryIsClean()
expected := []accessLogValue{

View file

@ -54,7 +54,8 @@ func init() {
check.Suite(&LogRotationSuite{})
check.Suite(&MarathonSuite{})
check.Suite(&MarathonSuite15{})
check.Suite(&RateLimitSuite{})
// TODO: disable temporarily
// check.Suite(&RateLimitSuite{})
check.Suite(&RestSuite{})
check.Suite(&RetrySuite{})
check.Suite(&SimpleSuite{})

View file

@ -55,18 +55,19 @@ frontendRedirect:
- traefik.http.middlewares.redirecthttp.redirectScheme.scheme=http
- traefik.http.middlewares.redirecthttp.redirectScheme.port=8000
- traefik.http.services.service3.loadbalancer.server.port=80
rateLimit:
image: containous/whoami
labels:
- traefik.enable=true
- traefik.http.routers.rt-rateLimit.entryPoints=httpRateLimit
- traefik.http.routers.rt-rateLimit.rule=Host("ratelimit.docker.local")
- traefik.http.routers.rt-rateLimit.middlewares=rate
- traefik.http.middlewares.rate.ratelimit.extractorfunc=client.ip
- traefik.http.middlewares.rate.ratelimit.rateset.Rate0.average=1
- traefik.http.middlewares.rate.ratelimit.rateset.Rate0.burst=2
- traefik.http.middlewares.rate.ratelimit.rateset.Rate0.period=10s
- traefik.http.services.service3.loadbalancer.server.port=80
# TODO: disable temporarily (rateLimit)
#rateLimit:
# image: containous/whoami
# labels:
# - traefik.enable=true
# - traefik.http.routers.rt-rateLimit.entryPoints=httpRateLimit
# - traefik.http.routers.rt-rateLimit.rule=Host("ratelimit.docker.local")
# - traefik.http.routers.rt-rateLimit.middlewares=rate
# - traefik.http.middlewares.rate.ratelimit.extractorfunc=client.ip
# - traefik.http.middlewares.rate.ratelimit.rateset.Rate0.average=1
# - traefik.http.middlewares.rate.ratelimit.rateset.Rate0.burst=2
# - traefik.http.middlewares.rate.ratelimit.rateset.Rate0.period=10s
# - traefik.http.services.service3.loadbalancer.server.port=80
frontendWhitelist:
image: containous/whoami
labels:

View file

@ -41,6 +41,8 @@ func (s *TracingSuite) startZipkin(c *check.C) {
}
func (s *TracingSuite) TestZipkinRateLimit(c *check.C) {
c.Skip("RateLimit is disable for now")
s.startZipkin(c)
defer s.composeProject.Stop(c, "zipkin")
file := s.adaptFile(c, "fixtures/tracing/simple-zipkin.toml", TracingTemplate{
@ -155,6 +157,8 @@ func (s *TracingSuite) startJaeger(c *check.C) {
}
func (s *TracingSuite) TestJaegerRateLimit(c *check.C) {
c.Skip("RateLimit is disable for now")
s.startJaeger(c)
defer s.composeProject.Stop(c, "jaeger")
file := s.adaptFile(c, "fixtures/tracing/simple-jaeger.toml", TracingTemplate{

View file

@ -24,7 +24,8 @@ type Middleware struct {
IPWhiteList *IPWhiteList `json:"ipWhiteList,omitempty" toml:"ipWhiteList,omitempty" yaml:"ipWhiteList,omitempty"`
Headers *Headers `json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty"`
Errors *ErrorPage `json:"errors,omitempty" toml:"errors,omitempty" yaml:"errors,omitempty"`
RateLimit *RateLimit `json:"rateLimit,omitempty" toml:"rateLimit,omitempty" yaml:"rateLimit,omitempty"`
// TODO: disable temporarily
// RateLimit *RateLimit `json:"rateLimit,omitempty" toml:"rateLimit,omitempty" yaml:"rateLimit,omitempty"`
RedirectRegex *RedirectRegex `json:"redirectRegex,omitempty" toml:"redirectRegex,omitempty" yaml:"redirectRegex,omitempty"`
RedirectScheme *RedirectScheme `json:"redirectScheme,omitempty" toml:"redirectScheme,omitempty" yaml:"redirectScheme,omitempty"`
BasicAuth *BasicAuth `json:"basicAuth,omitempty" toml:"basicAuth,omitempty" yaml:"basicAuth,omitempty"`

View file

@ -628,11 +628,6 @@ func (in *Middleware) DeepCopyInto(out *Middleware) {
*out = new(ErrorPage)
(*in).DeepCopyInto(*out)
}
if in.RateLimit != nil {
in, out := &in.RateLimit, &out.RateLimit
*out = new(RateLimit)
(*in).DeepCopyInto(*out)
}
if in.RedirectRegex != nil {
in, out := &in.RedirectRegex, &out.RedirectRegex
*out = new(RedirectRegex)

View file

@ -3,10 +3,8 @@ package label
import (
"fmt"
"testing"
"time"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -97,13 +95,14 @@ func TestDecodeConfiguration(t *testing.T) {
"traefik.http.middlewares.Middleware11.passtlsclientcert.info.issuer.province": "true",
"traefik.http.middlewares.Middleware11.passtlsclientcert.info.issuer.serialnumber": "true",
"traefik.http.middlewares.Middleware11.passtlsclientcert.pem": "true",
"traefik.http.middlewares.Middleware12.ratelimit.extractorfunc": "foobar",
"traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate0.average": "42",
"traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate0.burst": "42",
"traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate0.period": "42",
"traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate1.average": "42",
"traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate1.burst": "42",
"traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate1.period": "42",
// TODO: disable temporarily (rateLimit)
// "traefik.http.middlewares.Middleware12.ratelimit.extractorfunc": "foobar",
// "traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate0.average": "42",
// "traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate0.burst": "42",
// "traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate0.period": "42",
// "traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate1.average": "42",
// "traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate1.burst": "42",
// "traefik.http.middlewares.Middleware12.ratelimit.rateset.Rate1.period": "42",
"traefik.http.middlewares.Middleware13.redirectregex.permanent": "true",
"traefik.http.middlewares.Middleware13.redirectregex.regex": "foobar",
"traefik.http.middlewares.Middleware13.redirectregex.replacement": "foobar",
@ -306,23 +305,24 @@ func TestDecodeConfiguration(t *testing.T) {
},
},
},
"Middleware12": {
RateLimit: &dynamic.RateLimit{
RateSet: map[string]*dynamic.Rate{
"Rate0": {
Period: types.Duration(42 * time.Second),
Average: 42,
Burst: 42,
},
"Rate1": {
Period: types.Duration(42 * time.Second),
Average: 42,
Burst: 42,
},
},
ExtractorFunc: "foobar",
},
},
// TODO: disable temporarily (rateLimit)
// "Middleware12": {
// RateLimit: &dynamic.RateLimit{
// RateSet: map[string]*dynamic.Rate{
// "Rate0": {
// Period: types.Duration(42 * time.Second),
// Average: 42,
// Burst: 42,
// },
// "Rate1": {
// Period: types.Duration(42 * time.Second),
// Average: 42,
// Burst: 42,
// },
// },
// ExtractorFunc: "foobar",
// },
// },
"Middleware13": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: "foobar",
@ -702,23 +702,24 @@ func TestEncodeConfiguration(t *testing.T) {
},
},
},
"Middleware12": {
RateLimit: &dynamic.RateLimit{
RateSet: map[string]*dynamic.Rate{
"Rate0": {
Period: types.Duration(42 * time.Nanosecond),
Average: 42,
Burst: 42,
},
"Rate1": {
Period: types.Duration(42 * time.Nanosecond),
Average: 42,
Burst: 42,
},
},
ExtractorFunc: "foobar",
},
},
// TODO: disable temporarily (rateLimit)
// "Middleware12": {
// RateLimit: &dynamic.RateLimit{
// RateSet: map[string]*dynamic.Rate{
// "Rate0": {
// Period: types.Duration(42 * time.Nanosecond),
// Average: 42,
// Burst: 42,
// },
// "Rate1": {
// Period: types.Duration(42 * time.Nanosecond),
// Average: 42,
// Burst: 42,
// },
// },
// ExtractorFunc: "foobar",
// },
// },
"Middleware13": {
RedirectRegex: &dynamic.RedirectRegex{
Regex: "foobar",
@ -1051,13 +1052,14 @@ func TestEncodeConfiguration(t *testing.T) {
"traefik.HTTP.Middlewares.Middleware11.PassTLSClientCert.Info.Issuer.SerialNumber": "true",
"traefik.HTTP.Middlewares.Middleware11.PassTLSClientCert.Info.Issuer.DomainComponent": "true",
"traefik.HTTP.Middlewares.Middleware11.PassTLSClientCert.PEM": "true",
"traefik.HTTP.Middlewares.Middleware12.RateLimit.ExtractorFunc": "foobar",
"traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate0.Average": "42",
"traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate0.Burst": "42",
"traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate0.Period": "42",
"traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate1.Average": "42",
"traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate1.Burst": "42",
"traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate1.Period": "42",
// TODO: disable temporarily (rateLimit)
// "traefik.HTTP.Middlewares.Middleware12.RateLimit.ExtractorFunc": "foobar",
// "traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate0.Average": "42",
// "traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate0.Burst": "42",
// "traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate0.Period": "42",
// "traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate1.Average": "42",
// "traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate1.Burst": "42",
// "traefik.HTTP.Middlewares.Middleware12.RateLimit.RateSet.Rate1.Period": "42",
"traefik.HTTP.Middlewares.Middleware13.RedirectRegex.Regex": "foobar",
"traefik.HTTP.Middlewares.Middleware13.RedirectRegex.Replacement": "foobar",
"traefik.HTTP.Middlewares.Middleware13.RedirectRegex.Permanent": "true",

View file

@ -20,7 +20,6 @@ import (
"github.com/containous/traefik/pkg/middlewares/ipwhitelist"
"github.com/containous/traefik/pkg/middlewares/maxconnection"
"github.com/containous/traefik/pkg/middlewares/passtlsclientcert"
"github.com/containous/traefik/pkg/middlewares/ratelimiter"
"github.com/containous/traefik/pkg/middlewares/redirect"
"github.com/containous/traefik/pkg/middlewares/replacepath"
"github.com/containous/traefik/pkg/middlewares/replacepathregex"
@ -232,15 +231,16 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
}
}
// TODO: disable temporarily (rateLimit)
// RateLimit
if config.RateLimit != nil {
if middleware != nil {
return nil, badConf
}
middleware = func(next http.Handler) (http.Handler, error) {
return ratelimiter.New(ctx, next, *config.RateLimit, middlewareName)
}
}
// if config.RateLimit != nil {
// if middleware != nil {
// return nil, badConf
// }
// middleware = func(next http.Handler) (http.Handler, error) {
// return ratelimiter.New(ctx, next, *config.RateLimit, middlewareName)
// }
// }
// RedirectRegex
if config.RedirectRegex != nil {