Detect port the server is running on; needed for redirects and other full URLs