GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - FND/dprox: declarative reverse proxy for local development

BranchesTags
Open more actions menu

Latest commit

 

History

15 Commits
15 Commits

Folders and files

NameName
Last commit message
Last commit date
.editorconfig
.editorconfig
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
README.md
README.md
 
 
dprox.js
dprox.js
 
 
package.json
package.json
 
 
release
release
 
 

Repository files navigation

dprox – declarative reverse proxy for local development

Greenkeeper badge

a simple wrapper around express-http-proxy

Getting Started

ensure Node is available, then install dprox:

$ npm install dprox

create a proxy.config.js:

module.exports = {
    self: "localhost:8080",
    "/foo": {
        uri: "localhost:8081",
        preserveHost: true,
        preservePrefix: true
    },
    "/bar": {
        uri: "localhost:8082",
        preserveHost: true
    },
    "/assets": "localhost:3000"
};

dprox starts the proxy, reading configuration from proxy.config.js within the current working directory

dprox -c /path/to/any.js reads a custom configuration file instead

(note that this assumes the dprox executable resides on your PATH, otherwise you might have to provide the full path to that file)

Configuration

proxy.config.js is expected to export an object mapping paths to applications

an optional self entry defines the proxy's own address (which defaults to "localhost:3333") - this is either a string or a { uri, limit } object (limit sets the request body size limit - see express-http-proxy documentation for details)

each entry is either a URI string, an Express middleware function (see below) or an object with the following options:

  • uri is the address to pass requests to
  • preserveHost: true passes the HTTP Host header through to the respective application
  • preservePrefix: true passes the entry's path (URI prefix) through to the respective application
  • insecure: true skips verification of SSL/TLS certificates
  • requestHeaders: an object of custom headers to add to any incoming request (e.g. { "X-TOKEN": "abc123" }) - these are added to and take precedence over any existing request headers
  • responseHeaders: an object of custom headers to add to any outgoing response (e.g. { "Cache-Control": "max-age=1" }) - these are added to and take precedence over any existing response headers
  • log, if truthy, activates logging for this entry
    • if the value is a function, it will be invoked with the respective HTTP request object (e.g. log: req => { console.log(req.method + req.url); })
    • otherwise the value, unless true, will be prepended to the default log message (e.g. log: "[PROXY]")

middleware functions to serve static files from a corresponding directory or to mock a JSON response might look like this:

    "/assets": require("express").static("static"),
    "/data": (req, res, next) => {
        let data = {
            foo: "hello",
            bar: "world"
        };
        return res.json(data);
    }

Contributing

  • npm install downloads dependencies
  • npm test checks code for stylistic consistency

About

declarative reverse proxy for local development

Resources

Readme
Activity

Stars

11 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.