TsgcWebSocketServer_HTTPAPI › 이벤트 › OnBeforeForwardHTTP
HTTP 요청이 다른 HTTP 서버로 전달(역방향 프록시)될 수 있도록 디스패치되기 전에 발생합니다.
property OnBeforeForwardHTTP: TsgcWSHTTPAPIBeforeForwardHTTP;
// TsgcWSHTTPAPIBeforeForwardHTTP = procedure(Connection : TsgcWSConnection_HTTPAPI; aRequestInfo: THttpServerRequest; aForward: TsgcWSServerForwardHTTP) of object
—
OnBeforeForwardHTTP는 HTTP.SYS를 통해 수신된 모든 HTTP 요청에 대해 발생하며 서버가 선택된 엔드포인트에 대한 리버스 프록시 역할을 하도록 합니다. aRequestInfo.Document를 검사하여 요청을 전달해야 하는지 결정하십시오. 전달해야 하는 경우 aForward.Enabled를 True로 설정하고 aForward.URL을 대상 서버로 할당하십시오. aForward 객체의 추가 속성은 전달된 요청을 세밀하게 조정합니다: Document(대상 경로 재정의), QueryParams, Host, Origin, CustomHeaders, LogFilename, NoCache 및 HTTPS 대상을 위한 TLSOptions. aForward.Enabled가 False로 유지되면 요청은 평소처럼 OnHTTPRequest를 통해 로컬에서 처리됩니다.
procedure OnBeforeForwardHTTP(Connection: TsgcWSConnection_HTTPAPI;
aRequestInfo: THttpServerRequest; aForward: TsgcWSServerForwardHTTP);
begin
if aRequestInfo.Document = '/internal' then
begin
aForward.Enabled := True;
aForward.URL := 'http://localhost:8080';
end;
end;