Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host header may cause some sites not to be proxyable with changeOrigin enabled #458

Open
janjongboom opened this issue Sep 12, 2013 · 2 comments

Comments

@janjongboom
Copy link
Contributor

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.

@edef1c
Copy link

edef1c commented Sep 13, 2013

Hey Jan - pullreq certainly welcome! (we have an incomplete pullreq for this already)

janjongboom added a commit to janjongboom/node-http-proxy that referenced this issue Sep 15, 2013
indexzero pushed a commit that referenced this issue Dec 27, 2013
notatestuser added a commit to notatestuser/node-http-proxy that referenced this issue Feb 5, 2014
Version 0.10.4

* tag 'v0.10.4':
  [dist] Version bump. 0.10.4
  [dist] Bump dependencies.
  added option for eventlistenerCount(max)
  added unlimited listeners to the reverproxy event obj.
  [fix] Optimize fix for `x-forwarded-for-port`.
  determine x-forwarded-port from host header
  [dist minor] 2 space indents next time @samalba
  Prevent headers to be sent twice
  Put the arguments the right way around in the README.
  Put the arguments the right way around in emitter.
  Update the README to describe middleware err handler.
  Emit middlewareError when on middleware error.
  Fix for http-party#458. Host header may cause some sites not to be proxyable with changeOrigin enabled
  [fix] remove old reminescence
  Update README.md
  [fix] add 0.10 link, fixes http-party#459
  Send path in req.path and not the url

Conflicts:
	lib/node-http-proxy/http-proxy.js
@wclr
Copy link

wclr commented Oct 28, 2014

When you going to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants