diff --git a/README.md b/README.md index 07a3d14..cbd0f82 100644 --- a/README.md +++ b/README.md @@ -77,12 +77,27 @@ Forward all requests to the host specified. Only requests made with the prefix i // [METHOD] /foo/users => proxied to [METHOD] //www.foo.com/users ``` +## Proxy To Virtual host Website + +Virtual host refers to HTTP header `host`. If proxy target is a virtual host website, set the header `host`'s value to the website domain name + +```javascript + server.use(proxy('www.foo.com', { + request : { + headers : { + 'host' : 'www.foo.com', + } + } + })); +``` + + ## Proxy With Configuration Allows complex configuration. More details in the [configuration section](#configuration-options) ```javascript - server.use(proxy('ww.foo.com', { + server.use(proxy('www.foo.com', { prefix : 'foo', request : { forceHttps : true, diff --git a/lib/proxy.js b/lib/proxy.js index e617f34..6634b34 100644 --- a/lib/proxy.js +++ b/lib/proxy.js @@ -152,7 +152,7 @@ function buildResultingMiddleware (host, options, sharedStream) { // compile the request object used for the `request` module call // - req.headers.host = host; + //req.headers.host = host; let reqOpts = { url : URL.format(proxyUrl), diff --git a/test/core_integration_tests.js b/test/core_integration_tests.js index 5f866fc..a4ece6f 100644 --- a/test/core_integration_tests.js +++ b/test/core_integration_tests.js @@ -24,6 +24,7 @@ describe('Core Integration Tests', function () { strictSSL : false, headers : { 'User-Agent' : 'Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36', + 'host' : 'api.github.com', Authorization : require('./github_auth_header') } }, @@ -41,6 +42,7 @@ describe('Core Integration Tests', function () { request : { headers : { 'User-Agent' : 'Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36', + 'host' : 'i.imgur.com', } } })); diff --git a/test/regression_tests.js b/test/regression_tests.js index ef0fa5c..4c30578 100644 --- a/test/regression_tests.js +++ b/test/regression_tests.js @@ -25,6 +25,7 @@ describe('Regression Tests', function () { strictSSL : false, headers : { 'User-Agent' : 'Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36', + 'host' : 'api.github.com', Authorization : require('./github_auth_header') } }