Skip to content

Express/Connect HTTP proxy middleware

Notifications You must be signed in to change notification settings

foo4u/connect-http-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

connect-http-proxy

A simple HTTP/HTTPS proxy for Express/Connect based applications.

Install

npm i --save connect-http-proxy

Usage

const express = require("express");
const HttpProxy = require("./index");
const app = express();
const proxy = new HttpProxy({ hostname: "example.com" });

app.use("/proxy", proxy.handle());

Configuration options

  • protocol: Protocol to use. Defaults to http:.
  • hostname: A domain name or IP address of the server to proxy the requests to.
  • port Port of remote server. Defaults to 80.
  • timeout : A number specifying the socket timeout in milliseconds. This will set the timeout before the socket is connected.

HTTPS

To proxy an HTTPS host, simply set the protocol to https:

const proxy = new HttpProxy({
    hostname: "example.com",
    protocol: "https:"
});