Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions test/core_integration_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
},
Expand All @@ -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',
}
}
}));
Expand Down
1 change: 1 addition & 0 deletions test/regression_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
Expand Down