1
0
mirror of https://github.com/umputun/reproxy.git synced 2024-11-16 20:25:52 +02:00

fix order of middlewares to handle limiting by IP after match handler sets ctx

This commit is contained in:
Umputun 2023-11-26 17:10:16 -06:00
parent 672d4c2af8
commit bddb144f60
2 changed files with 13 additions and 12 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ docker-compose-private.yml
.vscode .vscode
.idea .idea
*.gpg *.gpg
reproxy-private.yml

View File

@ -121,19 +121,19 @@ func (h *Http) Run(ctx context.Context) error {
}() }()
handler := R.Wrap(h.proxyHandler(), handler := R.Wrap(h.proxyHandler(),
R.Recoverer(log.Default()), // recover on errors R.Recoverer(log.Default()), // recover on errors
signatureHandler(h.Signature, h.Version), // send app signature signatureHandler(h.Signature, h.Version), // send app signature
h.OnlyFrom.Handler, // limit source (remote) IPs if defined h.pingHandler, // respond to /ping
h.pingHandler, // respond to /ping
basicAuthHandler(h.BasicAuthEnabled, h.BasicAuthAllowed), // basic auth basicAuthHandler(h.BasicAuthEnabled, h.BasicAuthAllowed), // basic auth
h.healthMiddleware, // respond to /health h.healthMiddleware, // respond to /health
h.matchHandler, // set matched routes to context h.matchHandler, // set matched routes to context
limiterSystemHandler(h.ThrottleSystem), // limit total requests/sec h.OnlyFrom.Handler, // limit source (remote) IPs if defined
limiterUserHandler(h.ThrottleUser), // req/seq per user/route match limiterSystemHandler(h.ThrottleSystem), // limit total requests/sec
h.mgmtHandler(), // handles /metrics and /routes for prometheus limiterUserHandler(h.ThrottleUser), // req/seq per user/route match
h.pluginHandler(), // prc to external plugins h.mgmtHandler(), // handles /metrics and /routes for prometheus
headersHandler(h.ProxyHeaders, h.DropHeader), // add response headers and delete some request headers h.pluginHandler(), // prc to external plugins
accessLogHandler(h.AccessLog), // apache-format log file headersHandler(h.ProxyHeaders, h.DropHeader), // add response headers and delete some request headers
accessLogHandler(h.AccessLog), // apache-format log file
stdoutLogHandler(h.StdOutEnabled, logger.New(logger.Log(log.Default()), logger.Prefix("[INFO]")).Handler), stdoutLogHandler(h.StdOutEnabled, logger.New(logger.Log(log.Default()), logger.Prefix("[INFO]")).Handler),
maxReqSizeHandler(h.MaxBodySize), // limit request max size maxReqSizeHandler(h.MaxBodySize), // limit request max size
gzipHandler(h.GzEnabled), // gzip response gzipHandler(h.GzEnabled), // gzip response