proxymenu v0.6.3
proxymenu: Configure, run, and list HTTP proxy servers
proxymenu lets you configure and run multiple HTTP proxy servers (using Node Express and http-proxy-middleware) and render a list of your running proxy servers in a web browser.
Installation
npm install proxymenu
Usage
proxymenu exports the following functions:
startProxyMenu(options)
Runs a web server on the specified port number, which simply responds with an HTML table of the running proxy servers, giving the name and HTTP URL link of each proxy server.
options
(Object)title
: (string) title text to appear above the proxy menu table; defaults to "Proxy Menu"port
: (number) local port numbertimeout
: (number) milliseconds after which a request should receive a timeout error response
Returns: ProxyMenu Object, which should be passed as the proxyMenu
option in all calls to the startProxy
function.
startProxy(options)
Run an HTTP proxy server configured by the specified options.
options
(Object)port
(number): local port number of proxy serverpath
(string): URL path that must be matched on requests to this proxy servertimeout
(number): milliseconds after which a request should receive a timeout error responsename
(string): Unique identifier for this proxy server, which will appear in the proxy menu; seestartProxyMenu
function aboveproxyMenu
(ProxyMenu Object): SeestartProxyMenu
function abovetargets
(Array of TargetConfig Objects)
Each target config object may define:
path
(string) orpaths
(Array of string): the HTTP request URL path(s) to be matched to this targetsockets
(boolean): Set totrue
to enable WebSockets from proxy port to this targetmiddleware
(Function): When provided, this Express middleware function will be used to handle requests, ignoring all other options belowtarget
(string): If given, the URL of the target HTTP serverbody
(string): Whentarget
is omitted, usebody
to specify the response body (usually HTML or plain text) that should be returned to matching requestsheaders
Object: Whentarget
is omitted,headers
to specify the response headers (usually HTML or plain text) that should be returned to matching requestsmethods
(Array of string): HTTP methods to be matched to this targetpathRewrite
(Function): takes request URL path as parameter and returns a new path to be used in the proxied request to the target HTTP server- Additional options may be specified and will be passed to the
createProxyMiddleware
method of http-proxy-middleware.
Each target config should specify a target
or a body
; if both are specified, target
will have precedence, and body
will be ignored.
Only one target of a proxy server may have sockets
enabled.
responseInterceptor
For convenience, proxymenu also exports the responseInterceptor
method from http-proxy-middleware. See the Response Interceptor guide for more info and examples.