Protocols: Improved support for reverse proxys. Fixes [bug 7385].

Use the actual port number rather than the port number from the Host-
header when determining which configuration a request belongs to. They
may differ when eg the request comes via a proxy on a different port.
Merge branch 'patches/bug7385' into 5.2

* patches/bug7385:
  Protocols: Improved support for reverse proxys. Fixes [bug 7385].