Fix port determination

[fixes #492]

We were doing a port job of determining when to add the port to a fully
qualified url and erred on the side of doing it all the time rather than
doing it only when necessary. This could cause problems.

This will also require a configuration change on the server to make sure
that the protocol in the configuration is properly 'https' rather than
'http'.