Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

proxies to "localhost" virtual host #303

Closed
omares opened this Issue · 1 comment

3 participants

@omares

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

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.