0.6.3 • Published 6 months ago

proxymenu v0.6.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

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 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.

startProxy(options)

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; see startProxyMenu function above
    • proxyMenu (ProxyMenu Object): See startProxyMenu function above
    • targets (Array of TargetConfig Objects)

Each target config object may define:

  • path (string) or paths (Array of string): the HTTP request URL path(s) to be matched to this target
  • sockets (boolean): Set to true 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): When target is omitted, use body to specify the response body (usually HTML or plain text) that should be returned to matching requests
  • headers Object: When target 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.

responseInterceptor

For convenience, proxymenu also exports the responseInterceptor method from http-proxy-middleware. See the Response Interceptor guide for more info and examples.

0.6.3

6 months ago

0.6.2

6 months ago

0.6.1

6 months ago

0.6.0

6 months ago

0.5.1

10 months ago

0.5.0

11 months ago