SSX3LobbyServer/lib/http/proxy_address.hpp

23 lines
869 B
C++

#pragma once
// clang-format off
#include <http/config.hpp>
#include <impl/asio_config.hpp>
// clang-format on
#include <boost/beast/http/message.hpp>
#include <boost/beast/http/string_body.hpp>
namespace base::http {
/// A helper which returns the real IP address of a user behind a reverse proxy such as
/// NGINX, Apache, Caddy, or CloudFlare (or other reverse proxies - this list does not pretend to be exhaustive).
///
/// # Remarks
/// If BASE_HTTP_REVERSE_PROXY_SUPPORT is not defined, this function
/// simply returns the fallback address, so it is safe to use in all contexts where a proxied
/// address might be used (in fact, it might be a good idea to just leave calls in regardless of configuration.)
asio::ip::address GetProxyAddress(asio::ip::address fallback, beast::http::request<beast::http::string_body>& req);
} // namespace base::http