Skip to content

Commit

Permalink
Fix for #458. Host header may cause some sites not to be proxyable wi…
Browse files Browse the repository at this point in the history
…th changeOrigin enabled
  • Loading branch information
janjongboom authored and indexzero committed Dec 27, 2013
1 parent d60f1a9 commit 781c038
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
// don't revert this without documenting it!
//
if (this.changeOrigin) {
outgoing.headers.host = this.target.host + ':' + this.target.port;
outgoing.headers.host = this.target.host;
// Only add port information to the header if not default port
// for this protocol.
// See https://github.com/nodejitsu/node-http-proxy/issues/458
if (this.target.port !== 443 && this.target.https ||
this.target.port !== 80 && !this.target.https) {
outgoing.headers.host += ':' + this.target.port;
}
}

//
Expand Down

0 comments on commit 781c038

Please sign in to comment.