diff --git a/lib/https/index.js b/lib/https/index.js index 1f16dc2b4..bdaf3569e 100644 --- a/lib/https/index.js +++ b/lib/https/index.js @@ -34,7 +34,10 @@ function handleWebsocket(socket, wss, callback) { var fullUrl = socket.fullUrl; var options = url.parse(fullUrl); var _rules = reqEmitter.rules; - var proxyUrl = util.rule.getMatcher(_rules.proxy); + var proxyUrl = util.rule.getMatcher(_rules.rule); + if (proxyUrl && !util.isProxyProtocol(url.parse(proxyUrl).protocol)) { + proxyUrl = null; + } var reqSocket, options, matchedUrl; var now = Date.now(); var timeout, done; @@ -82,6 +85,7 @@ function handleWebsocket(socket, wss, callback) { if (proxyUrl) { var isSocks = /^socks:\/\//.test(proxyUrl); + reqEmitter.realUrl = proxyUrl; proxyUrl = (wss ? 'wss:' : 'ws:') + util.removeProtocol(proxyUrl); resolveHost(proxyUrl, function(ip) { options = url.parse(proxyUrl); diff --git a/lib/index.js b/lib/index.js index 36524b3a7..b804b439a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -33,7 +33,10 @@ function tunnelProxy(server, proxy) { return; } - var proxyUrl = util.rule.getMatcher(_rules.proxy); + var proxyUrl = util.rule.getMatcher(_rules.rule); + if (proxyUrl && !util.isProxyProtocol(url.parse(proxyUrl).protocol)) { + proxyUrl = null; + } if (proxyUrl) { var isSocks = /^socks:\/\//.test(proxyUrl);