Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

83
Vistas
Node.js Proxy Server on Localhost Always Returns Empty Response

I've been working on a personal project lately, and it involves intercepting any HTTP/S requests coming from my PC to external servers (that includes requesting through browsers, curl, etc.) and sometimes redirecting requests to a personal page depending on the requested hostname.

In order to get a proof-of-concept for intercepting and forwarding requests, I built a quick HTTPS proxy server in Node.js. It shouldn't really do anything other than printing some information about each request and forwarding it to where it was supposed to go.

Here's the main part of it:

var https = require('https');
var httpProxy = require('http-proxy');
var fs = require('fs');
var path = require('path');

const options = {
    ssl: {
      key: fs.readFileSync(path.resolve(__dirname, './mycert.key'), 'utf8'),
      cert: fs.readFileSync(path.resolve(__dirname, './mycert.crt'), 'utf8')
    },
    secure: false,
    toProxy: true
  }
const proxy = httpProxy.createProxyServer(options);

const httpsServer = https.createServer(options.ssl, (req, res) => {
    console.log("WEBSERVER")
    console.log(req.headers.host);
    proxy.web(req, res, {
      target: req.headers.host,
    })
})

const httpsListener = httpsServer.listen(8080);

console.log("LISTENING ON 8080")

Problem is, whenever I turn my Windows proxy settings to go to my new server, any request made through a browser just gives me an ERR_EMPTY_RESPONSE, and nothing gets printed out in the console where I run the proxy.

If I do an HTTPS request directly to the proxy it does print what I need out, but obviously doesn't take me anywhere.

Any ideas about what I should try? To be honest, I'm not sure if it is even possible to make a "localhost" proxy server, so I might be completely off track :/.

Thanks!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda