Branch: Tag:

2014-12-15

2014-12-15 14:57:01 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Protocols: Improved support for reverse proxys. Fixes [bug 7385 (#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.

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2004, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.582 2009/01/21 13:07:29 mast Exp $"; + constant cvs_version = "$Id$";   // #define REQUEST_DEBUG   #define MAGIC_ERROR   
2535:    misc->host, raw_url);    }    -  string canon_hostport; +  string canon_host = "*:";    if (string host = misc->host) {    // Parse and canonicalize the host header for use in the url    // used for port matching.
2544:    // IPv6 address    sscanf(lower_case(host), "[%s]:%d", host, port);    host = Protocols.IPv6.normalize_addr_basic (host) || host; -  canon_hostport = "[" + host + "]:" + port; +  canon_host = "[" + host + "]:";    } else {    sscanf(lower_case(host), "%[^:]:%d", host, port); -  canon_hostport = host + ":" + port; +  canon_host = host + ":";    }    misc->hostname = host;    misc->port = port;
2555:       if( !conf || !(path = port_obj->path ) ||    (sizeof( path ) && !has_prefix(raw_url, path)) ) { -  // FIXME: port_obj->name & port_obj->default_port are constant +  // FIXME: port_obj->name & port_obj->port are constant    // consider caching them?    -  +  // NB: Ignore the port number from the host header here, as +  // the client may access us via a load balancing proxy +  // or similar on a different port than our actual port. +  // cf [bug 7385].    string port_match_url = (port_obj->url_prefix + -  (canon_hostport || ("*:" + port_obj->port)) + +  canon_host + port_obj->port +    raw_url);    conf = port_obj->find_configuration_for_url(port_match_url, this);