I am trying to make a proxy server that proxies user requests to websites. I use it by starting a node server and setting it as my computer's proxy. It works whenever I connect to a website with HTTP, but when I connect to a website with HTTPS (which happens for most websites), I get ERR_EMPTY_REPONSE, which means that the proxy server gave no response. I'm using the http-proxy node module, as shown below:var http = require('http'); let httpProxy = require('http-proxy'); let fs = require("fs"); let url = require("url"); let https = require('https'); var proxy = httpProxy.createProxyServer({}); var server = http.createServer(function(req, res) { let urlObj = url.parse(req.url, true); proxy.web(req, res, { target: `https://${urlObj.hostname}`, agent : https.globalAgent, ssl: { key: fs.readFileSync("key.pem", "utf8"), cert: fs.readFileSync("cert.pem", "utf8"), }, secure: true }); }); server.listen(8080); I am not sure what is causing this issue. I figured it had to do with SSL, so I passed SSL options into the server. That didn't stop the issue, so I tried setting the "secure" option. That didn't stop the issue either. What is causing this, and how can I fix it?
Submitted June 02, 2020 at 01:19AM by geetar123
No comments:
Post a Comment