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