Skip to content

sandeshdanwale/http-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##HTTP(s) Proxy Server

###HTTPs <-> HTTPs
var http = require('http') , https = require('https') , httpProxy = require('./http-proxy') , fs = require('fs');

// Create your proxy server and set the proxy_pass in the options.

httpProxy.createProxyServer({
  proxy_pass: 'localhost',
  port: 9000,
  ssl: {
    key: fs.readFileSync('key'),
    cert: fs.readFileSync('cer')
  }
}).listen(8000);

// Create your target server

https.createServer(
  ssl: {
    key: fs.readFileSync('key'),
    cert: fs.readFileSync('cer')
  }, function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
}).listen(9000);

##OR

HTTP <-> HTTP

var http = require('http')
  , https = require('https')
  , httpProxy = require('./http-proxy')
  , fs = require('fs');


https.createServer({
    key: fs.readFileSync('/home/advay/Documents/cert/ssl/keys/ca.key'),
    cert: fs.readFileSync('/home/advay/Documents/cert/ssl/certs/ca.cer')
  }, function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
}).listen(9000);


Create your proxy server and set the proxy_pass in the options.

httpProxy.createProxyServer({
  proxy_pass: 'localhost',
  port: 9000,
  ssl: {
    key: fs.readFileSync('/home/advay/Documents/cert/ssl/keys/ca.key'),
    cert: fs.readFileSync('/home/advay/Documents/cert/ssl/certs/ca.cer')
  }
}).listen(8000);

About

Just a proxy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published