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.
npm install proxymenu
proxymenu exports the following functions:
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 number -
timeout
: (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.
Run an HTTP proxy server configured by the specified options.
-
options
(Object)-
port
(number): local port number of proxy server -
path
(string): URL path that must be matched on requests to this proxy server -
timeout
(number): milliseconds after which a request should receive a timeout error response -
name
(string): Unique identifier for this proxy server, which will appear in the proxy menu; seestartProxyMenu
function above -
proxyMenu
(ProxyMenu Object): SeestartProxyMenu
function above -
targets
(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 target -
sockets
(boolean): Set totrue
to enable WebSockets from proxy port to this target -
middleware
(Function): When provided, this Express middleware function will be used to handle requests, ignoring all other options below -
target
(string): If given, the URL of the target HTTP server -
body
(string): Whentarget
is omitted, usebody
to specify the response body (usually HTML or plain text) that should be returned to matching requests -
headers
Object: Whentarget
is omitted,headers
to specify the response headers (usually HTML or plain text) that should be returned to matching requests -
methods
(Array of string): HTTP methods to be matched to this target -
pathRewrite
(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.
For convenience, proxymenu also exports the responseInterceptor
method from http-proxy-middleware. See the Response Interceptor guide for more info and examples.