fix: Resolve proxy ip before processing any request (#3006)

This commit is contained in:
Sergey Kuznetsov
2026-03-19 15:34:53 +00:00
committed by GitHub
parent 6ecca9e19c
commit d3381a1dab

View File

@@ -241,6 +241,16 @@ public:
if (ec)
return httpFail(ec, "read");
if (auto resolvedIp = proxyIpResolver_->resolveClientIp(clientIp_, req_);
resolvedIp != clientIp_) {
LOG(log_.info()) << tag()
<< "Detected a forwarded request from proxy. Proxy ip: " << clientIp_
<< ". Resolved client ip: " << resolvedIp;
dosGuard_.get().decrement(clientIp_);
clientIp_ = std::move(resolvedIp);
dosGuard_.get().increment(clientIp_);
}
if (req_.method() == http::verb::get and req_.target() == "/health")
return sender_(httpResponse(http::status::ok, "text/html", kHEALTH_CHECK_HTML));
@@ -256,16 +266,6 @@ public:
));
}
if (auto resolvedIp = proxyIpResolver_->resolveClientIp(clientIp_, req_);
resolvedIp != clientIp_) {
LOG(log_.info()) << tag()
<< "Detected a forwarded request from proxy. Proxy ip: " << clientIp_
<< ". Resolved client ip: " << resolvedIp;
dosGuard_.get().decrement(clientIp_);
clientIp_ = std::move(resolvedIp);
dosGuard_.get().increment(clientIp_);
}
// Update isAdmin property of the connection
ConnectionBase::isAdmin_ = adminVerification_->isAdmin(req_, clientIp_);