diff --git a/docs/node-http-proxy.html b/docs/node-http-proxy.html index 3403749..c1ecff1 100644 --- a/docs/node-http-proxy.html +++ b/docs/node-http-proxy.html @@ -182,6 +182,7 @@ for managing the life-cycle of streaming reverse proxyied HTTP requests.
options = options || {}; options.target = options.target || {}; + this.https = options.https; this.forward = options.forward; this.target = options.target; this.changeOrigin = options.changeOrigin || false; @@ -517,25 +518,29 @@ to replace 'host' and 'origin' in response so we split data to printable data and to non-printable. (Non-printable will come after double-CRLF). var sdata = data.toString();Get the Printable data
sdata = sdata.substr(0, sdata.search(CRLF + CRLF));Get the Non-Printable data
data = data.slice(Buffer.byteLength(sdata), data.length);Replace the host and origin headers in the Printable data
sdata = sdata.replace(remoteHost, options.host)
.replace(remoteHost, options.host);
+
+ if (self.https && !self.target.https) {If the proxy server is running HTTPS but the client is running
+HTTP then replace ws with wss in the data sent back to the client.
sdata = sdata.replace('ws:', 'wss:');
+ }
- try {Write the printable and non-printable data to the socket + try {
Write the printable and non-printable data to the socket from the original incoming request.
socket.write(sdata);
socket.write(data);
}
catch (ex) {
proxyError(ex)
- }Catch socket errors
socket.on('error', proxyError);Remove data listener now that the 'handshake' is complete
reverseProxy.socket.removeListener('data', handshake);
+ }Catch socket errors
socket.on('error', proxyError);Remove data listener now that the 'handshake' is complete
reverseProxy.socket.removeListener('data', handshake);
});
}
reverseProxy.on('error', proxyError);
- try {Attempt to write the upgrade-head to the reverseProxy request.
reverseProxy.write(head);
+ try {Attempt to write the upgrade-head to the reverseProxy request.
reverseProxy.write(head);
}
catch (ex) {
proxyError(ex);
}
- If we have been passed buffered data, resume it.
if (options.buffer && !errState) {
+ If we have been passed buffered data, resume it.
if (options.buffer && !errState) {
options.buffer.resume();
}
};