diff --git a/lib/middleware/proxy.js b/lib/middleware/proxy.js index f58e39ff6..618455d65 100644 --- a/lib/middleware/proxy.js +++ b/lib/middleware/proxy.js @@ -35,6 +35,7 @@ var parseProxyConfig = function (proxies, config) { } var hostname = proxyDetails.hostname || config.hostname + var protocol = proxyDetails.protocol || config.protocol var port = proxyDetails.port || config.port || (proxyDetails.protocol === 'https:' ? '443' : '80') var https = proxyDetails.protocol === 'https:' @@ -43,7 +44,8 @@ var parseProxyConfig = function (proxies, config) { target: { host: hostname, port: port, - https: https + https: https, + protocol: protocol }, xfwd: true, secure: config.proxyValidateSSL diff --git a/test/unit/middleware/proxy.spec.js b/test/unit/middleware/proxy.spec.js index d44961128..04fef3804 100644 --- a/test/unit/middleware/proxy.spec.js +++ b/test/unit/middleware/proxy.spec.js @@ -166,7 +166,7 @@ describe('middleware.proxy', () => { expect(parsedProxyConfig[0].proxy).to.exist }) - it('should set defualt https port', () => { + it('should set default https port', () => { var proxy = {'/base/': 'https://localhost/'} var parsedProxyConfig = m.parseProxyConfig(proxy, {}) expect(parsedProxyConfig).to.have.length(1) @@ -178,6 +178,13 @@ describe('middleware.proxy', () => { https: true }) expect(parsedProxyConfig[0].proxy).to.exist + expect(parsedProxyConfig[0].proxy).to.containSubset({ + options: { + target: { + protocol: 'https:' + } + } + }) }) it('should handle proxy configs with paths', () => { @@ -206,6 +213,13 @@ describe('middleware.proxy', () => { https: true }) expect(parsedProxyConfig[0].proxy).to.exist + expect(parsedProxyConfig[0].proxy).to.containSubset({ + options: { + target: { + protocol: 'https:' + } + } + }) }) it('should handle proxy configs with only basepaths', () => {