Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'app.go')
-rw-r--r--app.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/app.go b/app.go
index 23e8a3cd..27094cff 100644
--- a/app.go
+++ b/app.go
@@ -32,6 +32,7 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/internal/logging"
"gitlab.com/gitlab-org/gitlab-pages/internal/netutil"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/ratelimiter"
"gitlab.com/gitlab-org/gitlab-pages/internal/rejectmethods"
"gitlab.com/gitlab-org/gitlab-pages/internal/request"
"gitlab.com/gitlab-org/gitlab-pages/internal/routing"
@@ -262,6 +263,16 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) {
handler = routing.NewMiddleware(handler, a.source)
+ if a.config.RateLimit.SourceIPLimitPerSecond > 0 {
+ rl := ratelimiter.New(
+ ratelimiter.WithSourceIPLimitPerSecond(a.config.RateLimit.SourceIPLimitPerSecond),
+ ratelimiter.WithSourceIPBurstSize(a.config.RateLimit.SourceIPBurst),
+ ratelimiter.WithProxied(len(a.config.Listeners.Proxy) > 0),
+ )
+
+ handler = rl.SourceIPLimiter(handler)
+ }
+
// Health Check
handler, err = a.healthCheckMiddleware(handler)
if err != nil {