[ADDED] Server port unless it's behind SSL

Fixes #2246
Merge pull request #2258 from MPOS/issue-2246-template-urls

[ADDED] Server port unless it's behind SSL