Use HTTP_HOST preference if it exists, fix on HTTPS handling.