Fixed HTTPS support

Needed to set the remote port based on the protocol used.