improve self-url discovery

(use ports if not standard, use other vars for scheme, move / around as needed)
You've forgotten the braces :wink: