TsgcWebSocketServer_HTTPAPI › Events › OnBeforeForwardHTTP
Fires before an HTTP request is dispatched so it can be forwarded (reverse-proxied) to another HTTP server.
public event TsgcWSHTTPAPIBeforeForwardHTTPHandler OnBeforeForwardHTTP;
// delegate void TsgcWSHTTPAPIBeforeForwardHTTPHandler(TsgcWSConnection_HTTPAPI Connection, THttpServerRequest aRequestInfo, TsgcWSServerForwardHTTP aForward)
—
OnBeforeForwardHTTP is raised for every HTTP request received through HTTP.SYS and lets the server act as a reverse proxy for selected endpoints. Inspect aRequestInfo.Document to decide whether the request must be forwarded; when it must, set aForward.Enabled to True and assign aForward.URL to the target server. Additional properties on the aForward object fine-tune the forwarded request: Document (override the target path), QueryParams, Host, Origin, CustomHeaders, LogFilename, NoCache and TLSOptions for HTTPS targets. When aForward.Enabled stays False the request is served locally through OnHTTPRequest as usual.
void OnBeforeForwardHTTP(TsgcWSConnection_HTTPAPI Connection,
THttpServerRequest aRequestInfo, TsgcWSServerForwardHTTP aForward)
{
if (aRequestInfo.Document == "/internal")
{
aForward.Enabled = true;
aForward.URL = "http://localhost:8080";
}
}