daproxy
v0.0.6
Published
Reverse proxy and static server for local development
Downloads
5
Maintainers
Readme
DaProxy
Simple reverse proxy and HTTP server written in NodeJS using node-http-proxy and node-http-server.
This server is meant for development use, but it is based on production-ready proxy server from NodeJitsu. It is capable of listening on port 80 and thus serving as a frontend server. It serves static files and has support for directory indexes.
This package was previously known as DevProxy, but has been since renamed to avoid conflicts with other packages on NPM.
Installation
Install directly from this repository:
npm install daproxy
This creates a proxy
command that you can use to start the proxy.
Summary
proxy
proxy [-c] FILE
proxy [-p PORT] [-t TARGET] [-r ROOT_URL] [-s STATIC_DIR] [-n]
Run the following command to get more information about the relevant command line options:
node proxy.js -h
FILE
This argument is an optional configuration file that can be used to customize the defaults. The file should contain a single object with following optional keys:
baseDir
: Base directory for static files (default: 'www')target
: Target host to be proxied (default: 'http://localhost:80/api')rootPath
: The path at which proxied host is accessed locally (default: path portion oftarget
)port
: Port on which the proxy will listen (default: '8080')noLang
: Whether to prevent relaying of the 'Accept-Language' header (default: false)
The target host URL can use both http and https protocols. Currently username
and password embedded in the URL will be ignored. Please use some other form of
authentication if possible. The port and path are honored. The path portion
will also be used as the default value of rootPath
.
Since version 0.0.2, it is also possible to specify multiple targets and root paths. Use an array for each. When specifying multiple targets nad rootPaths, keep in mind that they are always paired, even though they are specified in separate keys. This is mostly for backwards compatibility of the configuration file format.
The noLang
option can be useful on misbehaving API servers that redirect to
language-specific URL instead of responding to requests. If you detect that the
responses are always redirects or HTTP 404 at wrong URL, try setting this
option to true. It is generally safe to have this set to true
on most API
servers, since API servers are not supposed to honor the Accept-Language
header anyway.
Example can be found in example/proxy.json
.
Volo target
Take a look at eample/volofile
for an example serve
target that uses this
script.
Support
This is an internal tool used at CloudHorizon. Although it is publicly accessible, and we generally support it for our own needs, don't expect to get support for it or anythhing along those lines. But reports are welcome, though, and we usually respond to them. Patches and pull requests are even more welcome.
Known issues
- This server always listens on all interfaces. This is not (yet) configurable.
- The URLs returned from the target host are not rewritten.