proxies to "localhost" virtual host #303

Closed
omares opened this Issue Aug 28, 2012 · 1 comment

Comments

Projects
None yet
3 participants
@omares

omares commented Aug 28, 2012

Hey,

shouldnt following snippet proxy every request made to localhost:8000 to my local nginx virtual host which runs under the domain "auth-request"? I am asking this because all request get forwarded to the default "localhost/127.0.0.1" virtual host. It seems that the request gets forwarded to the ip but the hostname is discarded?

var http = require('http'),
    httpProxy = require('http-proxy');

//
// Create a proxy server with custom application logic
//
httpProxy.createServer(function (req, res, proxy) {
  //
  // Put your custom server logic here
  //
  proxy.proxyRequest(req, res, {
    host: 'auth-request',
    port: 80
  });
}).listen(8000);
@1stvamp

This comment has been minimized.

Show comment Hide comment
@1stvamp

1stvamp Oct 17, 2012

Contributor

@omares by default http-proxy doesn't change the Host header to the targeted hostname, so Nginx doesn't know which host to match to.
You can force it by setting the changeOrigin option to true.

Contributor

1stvamp commented Oct 17, 2012

@omares by default http-proxy doesn't change the Host header to the targeted hostname, so Nginx doesn't know which host to match to.
You can force it by setting the changeOrigin option to true.

@indexzero indexzero closed this Nov 29, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment