Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

398
Views
Proxy https to http (example) not working - node-http-proxy

I have a HTTP web server and I'm trying to set it up behind a HTTPS proxy server. I've tried the example that's in the repository: https://github.com/http-party/node-http-proxy/blob/master/examples/http/proxy-https-to-http.js but I'm always getting ERR_EMPTY_RESPONSE in browser.

Example code

var https = require('https'),
    http  = require('http'),
    util  = require('util'),
    path  = require('path'),
    fs    = require('fs'),
    colors = require('colors'),
    httpProxy = require('../../lib/http-proxy'),
    fixturesDir = path.join(__dirname, '..', '..', 'test', 'fixtures');

//
// Create the target HTTP server
//
http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('hello http over https\n');
  res.end();
}).listen(9009);

//
// Create the HTTPS proxy server listening on port 8000
//
httpProxy.createServer({
  target: {
    host: 'localhost',
    port: 9009
  },
  ssl: {
    key: fs.readFileSync(path.join(fixturesDir, 'agent2-key.pem'), 'utf8'),
    cert: fs.readFileSync(path.join(fixturesDir, 'agent2-cert.pem'), 'utf8')
  }
}).listen(8009);

console.log('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8009'.yellow);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9009 '.yellow);

Error

Screenshot

Browser is pointed to use 127.0.0.1:8009 proxy.

Does anybody know what's wrong ? Any suggestion is appreciated.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!