I faced same issue and found correct answer:- use OnQuerySSLPort handler to enable SSL on non standard port otherwise it will work as HTTP server on non standard port.
That is correct. The
OnQuerySSLPort event tells you which port a client has connected to, and then you return whether that port should use SSL/TLS or not.
TIdHTTPServer will use SSL/TLS on the standard HTTPS port 443 by default, but you need to use the
OnQuerySSLPort event to activate SSL/TLS on any other non-standard port.
procedure TShttpsServer.HandleSslQuery(APort: TIdPort; var VUseSSL: Boolean);
begin
VUseSSL := True;
APort := 8080;
end;
You are telling the server to use SSL/TLS for
all clients unconditionally, regardless of which port each client has connected to. If you only have HTTPS ports, that's fine. But if you need to listen on both HTTP and HTTPS ports then your handler needs to look more like this instead:
procedure TShttpsServer.HandleSslQuery(APort: TIdPort; var VUseSSL: Boolean);
begin
VUseSSL := (APort = 8080); // whatever ports your HTTPS bindings are listening on
end;