Host header may cause some sites not to be proxyable with changeOrigin enabled
Created by: janjongboom
RFC 2616 Section 14.23 specifies that the port argument in the Host header is optional if connecting to default port (80 on HTTP f.e.). At the moment we always add the port, but I've encountered a website (10 mio pageviews a day) running IIS 7 that doesn't accept this host header and wants one without the port specified. See http://www.funda.nl. At the moment node-http-proxy doesn't work with this site if changeOrigin is enabled. Chrome f.e. doesn't add the port if doing a request for HTTP on port 80.
I'd suggest changing the codez to:
if (this.changeOrigin) {
outgoing.headers.host = this.target.host;
if (this.target.port !== 443 && this.target.https ||
this.target.port !== 80 && !this.target.https) {
outgoing.headers.host += ':' + this.target.port;
}
}
Let me know if this is OK, then I'll open a PR.