Skip to content
This repository has been archived by the owner on Apr 21, 2020. It is now read-only.

Commit

Permalink
Support reverse proxying in front of https servers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbreen committed Apr 26, 2015
1 parent 1fcd1b9 commit 6a987f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/proxy/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function ProxyConfig(config) {
Object.defineProperty(this_obj, 'https_cert_file', { 'value': config.https.cert, writable: false, enumerable: true });
}

// If we know that the host behind the reverse proxy is serving https but is not doing so on port 443, we can force
// the use of the HTTPS_AGENT by setting the secure config param.
Object.defineProperty(this_obj, 'secure', { 'value': config.secure, writable: false, enumerable: true });

// An optional object defining quotas to apply to inbound requests.
Object.defineProperty(this_obj, 'quotas', { 'value': (config.quotas || {thresholds:{}}), writable: false, enumerable: true});

Expand Down
4 changes: 3 additions & 1 deletion lib/proxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ Proxy.prototype.getConnectReverseProxyApp = function() {
function(req, res) {
// Proxy a web request to the target port on localhost using the provided agent.
// If no agent is provided, node-http-proxy will return a connection: close.
proxy.web(req, res, {agent: HTTP_AGENT, target: { 'host' : this_obj.config.target_host, 'port' : this_obj.config.to_port }});
var agent = this_obj.config.target_port === 443 || this_obj.config.secure ? HTTPS_AGENT : HTTP_AGENT;

proxy.web(req, res, {agent: agent, target: { 'host' : this_obj.config.target_host, 'port' : this_obj.config.to_port }});
}
);
};
Expand Down

0 comments on commit 6a987f6

Please sign in to comment.